1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.FileT; 26 27 public import gio.AppInfoIF; 28 public import gio.AsyncResultIF; 29 public import gio.Cancellable; 30 public import gio.FileAttributeInfoList; 31 public import gio.FileEnumerator; 32 public import gio.FileIF; 33 public import gio.FileIOStream; 34 public import gio.FileInfo; 35 public import gio.FileInputStream; 36 public import gio.FileMonitor; 37 public import gio.FileOutputStream; 38 public import gio.MountIF; 39 public import gio.MountOperation; 40 public import gio.c.functions; 41 public import gio.c.types; 42 public import glib.Bytes; 43 public import glib.ConstructionException; 44 public import glib.ErrorG; 45 public import glib.GException; 46 public import glib.Str; 47 public import glib.c.functions; 48 public import gobject.ObjectG; 49 50 51 /** 52 * #GFile is a high level abstraction for manipulating files on a 53 * virtual file system. #GFiles are lightweight, immutable objects 54 * that do no I/O upon creation. It is necessary to understand that 55 * #GFile objects do not represent files, merely an identifier for a 56 * file. All file content I/O is implemented as streaming operations 57 * (see #GInputStream and #GOutputStream). 58 * 59 * To construct a #GFile, you can use: 60 * - g_file_new_for_path() if you have a path. 61 * - g_file_new_for_uri() if you have a URI. 62 * - g_file_new_for_commandline_arg() for a command line argument. 63 * - g_file_new_tmp() to create a temporary file from a template. 64 * - g_file_parse_name() from a UTF-8 string gotten from g_file_get_parse_name(). 65 * - g_file_new_build_filename() to create a file from path elements. 66 * 67 * One way to think of a #GFile is as an abstraction of a pathname. For 68 * normal files the system pathname is what is stored internally, but as 69 * #GFiles are extensible it could also be something else that corresponds 70 * to a pathname in a userspace implementation of a filesystem. 71 * 72 * #GFiles make up hierarchies of directories and files that correspond to 73 * the files on a filesystem. You can move through the file system with 74 * #GFile using g_file_get_parent() to get an identifier for the parent 75 * directory, g_file_get_child() to get a child within a directory, 76 * g_file_resolve_relative_path() to resolve a relative path between two 77 * #GFiles. There can be multiple hierarchies, so you may not end up at 78 * the same root if you repeatedly call g_file_get_parent() on two different 79 * files. 80 * 81 * All #GFiles have a basename (get with g_file_get_basename()). These names 82 * are byte strings that are used to identify the file on the filesystem 83 * (relative to its parent directory) and there is no guarantees that they 84 * have any particular charset encoding or even make any sense at all. If 85 * you want to use filenames in a user interface you should use the display 86 * name that you can get by requesting the 87 * %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info(). 88 * This is guaranteed to be in UTF-8 and can be used in a user interface. 89 * But always store the real basename or the #GFile to use to actually 90 * access the file, because there is no way to go from a display name to 91 * the actual name. 92 * 93 * Using #GFile as an identifier has the same weaknesses as using a path 94 * in that there may be multiple aliases for the same file. For instance, 95 * hard or soft links may cause two different #GFiles to refer to the same 96 * file. Other possible causes for aliases are: case insensitive filesystems, 97 * short and long names on FAT/NTFS, or bind mounts in Linux. If you want to 98 * check if two #GFiles point to the same file you can query for the 99 * %G_FILE_ATTRIBUTE_ID_FILE attribute. Note that #GFile does some trivial 100 * canonicalization of pathnames passed in, so that trivial differences in 101 * the path string used at creation (duplicated slashes, slash at end of 102 * path, "." or ".." path segments, etc) does not create different #GFiles. 103 * 104 * Many #GFile operations have both synchronous and asynchronous versions 105 * to suit your application. Asynchronous versions of synchronous functions 106 * simply have _async() appended to their function names. The asynchronous 107 * I/O functions call a #GAsyncReadyCallback which is then used to finalize 108 * the operation, producing a GAsyncResult which is then passed to the 109 * function's matching _finish() operation. 110 * 111 * It is highly recommended to use asynchronous calls when running within a 112 * shared main loop, such as in the main thread of an application. This avoids 113 * I/O operations blocking other sources on the main loop from being dispatched. 114 * Synchronous I/O operations should be performed from worker threads. See the 115 * [introduction to asynchronous programming section][async-programming] for 116 * more. 117 * 118 * Some #GFile operations almost always take a noticeable amount of time, and 119 * so do not have synchronous analogs. Notable cases include: 120 * - g_file_mount_mountable() to mount a mountable file. 121 * - g_file_unmount_mountable_with_operation() to unmount a mountable file. 122 * - g_file_eject_mountable_with_operation() to eject a mountable file. 123 * 124 * ## Entity Tags # {#gfile-etag} 125 * 126 * One notable feature of #GFiles are entity tags, or "etags" for 127 * short. Entity tags are somewhat like a more abstract version of the 128 * traditional mtime, and can be used to quickly determine if the file 129 * has been modified from the version on the file system. See the 130 * HTTP 1.1 131 * [specification](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) 132 * for HTTP Etag headers, which are a very similar concept. 133 */ 134 public template FileT(TStruct) 135 { 136 /** Get the main Gtk struct */ 137 public GFile* getFileStruct(bool transferOwnership = false) 138 { 139 if (transferOwnership) 140 ownedRef = false; 141 return cast(GFile*)getStruct(); 142 } 143 144 145 /** 146 * Gets an output stream for appending data to the file. 147 * If the file doesn't already exist it is created. 148 * 149 * By default files created are generally readable by everyone, 150 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 151 * will be made readable only to the current user, to the level that 152 * is supported on the target filesystem. 153 * 154 * If @cancellable is not %NULL, then the operation can be cancelled 155 * by triggering the cancellable object from another thread. If the 156 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 157 * returned. 158 * 159 * Some file systems don't allow all file names, and may return an 160 * %G_IO_ERROR_INVALID_FILENAME error. If the file is a directory the 161 * %G_IO_ERROR_IS_DIRECTORY error will be returned. Other errors are 162 * possible too, and depend on what kind of filesystem the file is on. 163 * 164 * Params: 165 * flags = a set of #GFileCreateFlags 166 * cancellable = optional #GCancellable object, 167 * %NULL to ignore 168 * 169 * Returns: a #GFileOutputStream, or %NULL on error. 170 * Free the returned object with g_object_unref(). 171 * 172 * Throws: GException on failure. 173 */ 174 public FileOutputStream appendTo(GFileCreateFlags flags, Cancellable cancellable) 175 { 176 GError* err = null; 177 178 auto __p = g_file_append_to(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 179 180 if (err !is null) 181 { 182 throw new GException( new ErrorG(err) ); 183 } 184 185 if(__p is null) 186 { 187 return null; 188 } 189 190 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) __p, true); 191 } 192 193 /** 194 * Asynchronously opens @file for appending. 195 * 196 * For more details, see g_file_append_to() which is 197 * the synchronous version of this call. 198 * 199 * When the operation is finished, @callback will be called. 200 * You can then call g_file_append_to_finish() to get the result 201 * of the operation. 202 * 203 * Params: 204 * flags = a set of #GFileCreateFlags 205 * ioPriority = the [I/O priority][io-priority] of the request 206 * cancellable = optional #GCancellable object, 207 * %NULL to ignore 208 * callback = a #GAsyncReadyCallback to call 209 * when the request is satisfied 210 * userData = the data to pass to callback function 211 */ 212 public void appendToAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 213 { 214 g_file_append_to_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 215 } 216 217 /** 218 * Finishes an asynchronous file append operation started with 219 * g_file_append_to_async(). 220 * 221 * Params: 222 * res = #GAsyncResult 223 * 224 * Returns: a valid #GFileOutputStream 225 * or %NULL on error. 226 * Free the returned object with g_object_unref(). 227 * 228 * Throws: GException on failure. 229 */ 230 public FileOutputStream appendToFinish(AsyncResultIF res) 231 { 232 GError* err = null; 233 234 auto __p = g_file_append_to_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 235 236 if (err !is null) 237 { 238 throw new GException( new ErrorG(err) ); 239 } 240 241 if(__p is null) 242 { 243 return null; 244 } 245 246 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) __p, true); 247 } 248 249 /** 250 * Prepares the file attribute query string for copying to @file. 251 * 252 * This function prepares an attribute query string to be 253 * passed to g_file_query_info() to get a list of attributes 254 * normally copied with the file (see g_file_copy_attributes() 255 * for the detailed description). This function is used by the 256 * implementation of g_file_copy_attributes() and is useful 257 * when one needs to query and set the attributes in two 258 * stages (e.g., for recursive move of a directory). 259 * 260 * Params: 261 * flags = a set of #GFileCopyFlags 262 * cancellable = optional #GCancellable object, 263 * %NULL to ignore 264 * 265 * Returns: an attribute query string for g_file_query_info(), 266 * or %NULL if an error occurs. 267 * 268 * Since: 2.68 269 * 270 * Throws: GException on failure. 271 */ 272 public string buildAttributeListForCopy(GFileCopyFlags flags, Cancellable cancellable) 273 { 274 GError* err = null; 275 276 auto retStr = g_file_build_attribute_list_for_copy(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 277 278 if (err !is null) 279 { 280 throw new GException( new ErrorG(err) ); 281 } 282 283 scope(exit) Str.freeString(retStr); 284 return Str.toString(retStr); 285 } 286 287 /** 288 * Copies the file @source to the location specified by @destination. 289 * Can not handle recursive copies of directories. 290 * 291 * If the flag %G_FILE_COPY_OVERWRITE is specified an already 292 * existing @destination file is overwritten. 293 * 294 * If the flag %G_FILE_COPY_NOFOLLOW_SYMLINKS is specified then symlinks 295 * will be copied as symlinks, otherwise the target of the 296 * @source symlink will be copied. 297 * 298 * If the flag %G_FILE_COPY_ALL_METADATA is specified then all the metadata 299 * that is possible to copy is copied, not just the default subset (which, 300 * for instance, does not include the owner, see #GFileInfo). 301 * 302 * If @cancellable is not %NULL, then the operation can be cancelled by 303 * triggering the cancellable object from another thread. If the operation 304 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 305 * 306 * If @progress_callback is not %NULL, then the operation can be monitored 307 * by setting this to a #GFileProgressCallback function. 308 * @progress_callback_data will be passed to this function. It is guaranteed 309 * that this callback will be called after all data has been transferred with 310 * the total number of bytes copied during the operation. 311 * 312 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND error 313 * is returned, independent on the status of the @destination. 314 * 315 * If %G_FILE_COPY_OVERWRITE is not specified and the target exists, then 316 * the error %G_IO_ERROR_EXISTS is returned. 317 * 318 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 319 * error is returned. If trying to overwrite a directory with a directory the 320 * %G_IO_ERROR_WOULD_MERGE error is returned. 321 * 322 * If the source is a directory and the target does not exist, or 323 * %G_FILE_COPY_OVERWRITE is specified and the target is a file, then the 324 * %G_IO_ERROR_WOULD_RECURSE error is returned. 325 * 326 * If you are interested in copying the #GFile object itself (not the on-disk 327 * file), see g_file_dup(). 328 * 329 * Params: 330 * destination = destination #GFile 331 * flags = set of #GFileCopyFlags 332 * cancellable = optional #GCancellable object, 333 * %NULL to ignore 334 * progressCallback = function to callback with 335 * progress information, or %NULL if progress information is not needed 336 * progressCallbackData = user data to pass to @progress_callback 337 * 338 * Returns: %TRUE on success, %FALSE otherwise. 339 * 340 * Throws: GException on failure. 341 */ 342 public bool copy(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData) 343 { 344 GError* err = null; 345 346 auto __p = g_file_copy(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, &err) != 0; 347 348 if (err !is null) 349 { 350 throw new GException( new ErrorG(err) ); 351 } 352 353 return __p; 354 } 355 356 /** 357 * Copies the file @source to the location specified by @destination 358 * asynchronously. For details of the behaviour, see g_file_copy(). 359 * 360 * If @progress_callback is not %NULL, then that function that will be called 361 * just like in g_file_copy(). The callback will run in the default main context 362 * of the thread calling g_file_copy_async() — the same context as @callback is 363 * run in. 364 * 365 * When the operation is finished, @callback will be called. You can then call 366 * g_file_copy_finish() to get the result of the operation. 367 * 368 * Params: 369 * destination = destination #GFile 370 * flags = set of #GFileCopyFlags 371 * ioPriority = the [I/O priority][io-priority] of the request 372 * cancellable = optional #GCancellable object, 373 * %NULL to ignore 374 * progressCallback = function to callback with progress 375 * information, or %NULL if progress information is not needed 376 * progressCallbackData = user data to pass to @progress_callback 377 * callback = a #GAsyncReadyCallback to call when the request is satisfied 378 * userData = the data to pass to callback function 379 */ 380 public void copyAsync(FileIF destination, GFileCopyFlags flags, int ioPriority, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData, GAsyncReadyCallback callback, void* userData) 381 { 382 g_file_copy_async(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, callback, userData); 383 } 384 385 /** 386 * Copies the file attributes from @source to @destination. 387 * 388 * Normally only a subset of the file attributes are copied, 389 * those that are copies in a normal file copy operation 390 * (which for instance does not include e.g. owner). However 391 * if %G_FILE_COPY_ALL_METADATA is specified in @flags, then 392 * all the metadata that is possible to copy is copied. This 393 * is useful when implementing move by copy + delete source. 394 * 395 * Params: 396 * destination = a #GFile to copy attributes to 397 * flags = a set of #GFileCopyFlags 398 * cancellable = optional #GCancellable object, 399 * %NULL to ignore 400 * 401 * Returns: %TRUE if the attributes were copied successfully, 402 * %FALSE otherwise. 403 * 404 * Throws: GException on failure. 405 */ 406 public bool copyAttributes(FileIF destination, GFileCopyFlags flags, Cancellable cancellable) 407 { 408 GError* err = null; 409 410 auto __p = g_file_copy_attributes(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 411 412 if (err !is null) 413 { 414 throw new GException( new ErrorG(err) ); 415 } 416 417 return __p; 418 } 419 420 /** 421 * Finishes copying the file started with g_file_copy_async(). 422 * 423 * Params: 424 * res = a #GAsyncResult 425 * 426 * Returns: a %TRUE on success, %FALSE on error. 427 * 428 * Throws: GException on failure. 429 */ 430 public bool copyFinish(AsyncResultIF res) 431 { 432 GError* err = null; 433 434 auto __p = g_file_copy_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err) != 0; 435 436 if (err !is null) 437 { 438 throw new GException( new ErrorG(err) ); 439 } 440 441 return __p; 442 } 443 444 /** 445 * Creates a new file and returns an output stream for writing to it. 446 * The file must not already exist. 447 * 448 * By default files created are generally readable by everyone, 449 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 450 * will be made readable only to the current user, to the level 451 * that is supported on the target filesystem. 452 * 453 * If @cancellable is not %NULL, then the operation can be cancelled 454 * by triggering the cancellable object from another thread. If the 455 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 456 * returned. 457 * 458 * If a file or directory with this name already exists the 459 * %G_IO_ERROR_EXISTS error will be returned. Some file systems don't 460 * allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME 461 * error, and if the name is to long %G_IO_ERROR_FILENAME_TOO_LONG will 462 * be returned. Other errors are possible too, and depend on what kind 463 * of filesystem the file is on. 464 * 465 * Params: 466 * flags = a set of #GFileCreateFlags 467 * cancellable = optional #GCancellable object, 468 * %NULL to ignore 469 * 470 * Returns: a #GFileOutputStream for the newly created 471 * file, or %NULL on error. 472 * Free the returned object with g_object_unref(). 473 * 474 * Throws: GException on failure. 475 */ 476 public FileOutputStream create(GFileCreateFlags flags, Cancellable cancellable) 477 { 478 GError* err = null; 479 480 auto __p = g_file_create(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 481 482 if (err !is null) 483 { 484 throw new GException( new ErrorG(err) ); 485 } 486 487 if(__p is null) 488 { 489 return null; 490 } 491 492 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) __p, true); 493 } 494 495 /** 496 * Asynchronously creates a new file and returns an output stream 497 * for writing to it. The file must not already exist. 498 * 499 * For more details, see g_file_create() which is 500 * the synchronous version of this call. 501 * 502 * When the operation is finished, @callback will be called. 503 * You can then call g_file_create_finish() to get the result 504 * of the operation. 505 * 506 * Params: 507 * flags = a set of #GFileCreateFlags 508 * ioPriority = the [I/O priority][io-priority] of the request 509 * cancellable = optional #GCancellable object, 510 * %NULL to ignore 511 * callback = a #GAsyncReadyCallback to call 512 * when the request is satisfied 513 * userData = the data to pass to callback function 514 */ 515 public void createAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 516 { 517 g_file_create_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 518 } 519 520 /** 521 * Finishes an asynchronous file create operation started with 522 * g_file_create_async(). 523 * 524 * Params: 525 * res = a #GAsyncResult 526 * 527 * Returns: a #GFileOutputStream or %NULL on error. 528 * Free the returned object with g_object_unref(). 529 * 530 * Throws: GException on failure. 531 */ 532 public FileOutputStream createFinish(AsyncResultIF res) 533 { 534 GError* err = null; 535 536 auto __p = g_file_create_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 537 538 if (err !is null) 539 { 540 throw new GException( new ErrorG(err) ); 541 } 542 543 if(__p is null) 544 { 545 return null; 546 } 547 548 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) __p, true); 549 } 550 551 /** 552 * Creates a new file and returns a stream for reading and 553 * writing to it. The file must not already exist. 554 * 555 * By default files created are generally readable by everyone, 556 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 557 * will be made readable only to the current user, to the level 558 * that is supported on the target filesystem. 559 * 560 * If @cancellable is not %NULL, then the operation can be cancelled 561 * by triggering the cancellable object from another thread. If the 562 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 563 * returned. 564 * 565 * If a file or directory with this name already exists, the 566 * %G_IO_ERROR_EXISTS error will be returned. Some file systems don't 567 * allow all file names, and may return an %G_IO_ERROR_INVALID_FILENAME 568 * error, and if the name is too long, %G_IO_ERROR_FILENAME_TOO_LONG 569 * will be returned. Other errors are possible too, and depend on what 570 * kind of filesystem the file is on. 571 * 572 * Note that in many non-local file cases read and write streams are 573 * not supported, so make sure you really need to do read and write 574 * streaming, rather than just opening for reading or writing. 575 * 576 * Params: 577 * flags = a set of #GFileCreateFlags 578 * cancellable = optional #GCancellable object, 579 * %NULL to ignore 580 * 581 * Returns: a #GFileIOStream for the newly created 582 * file, or %NULL on error. 583 * Free the returned object with g_object_unref(). 584 * 585 * Since: 2.22 586 * 587 * Throws: GException on failure. 588 */ 589 public FileIOStream createReadwrite(GFileCreateFlags flags, Cancellable cancellable) 590 { 591 GError* err = null; 592 593 auto __p = g_file_create_readwrite(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 594 595 if (err !is null) 596 { 597 throw new GException( new ErrorG(err) ); 598 } 599 600 if(__p is null) 601 { 602 return null; 603 } 604 605 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) __p, true); 606 } 607 608 /** 609 * Asynchronously creates a new file and returns a stream 610 * for reading and writing to it. The file must not already exist. 611 * 612 * For more details, see g_file_create_readwrite() which is 613 * the synchronous version of this call. 614 * 615 * When the operation is finished, @callback will be called. 616 * You can then call g_file_create_readwrite_finish() to get 617 * the result of the operation. 618 * 619 * Params: 620 * flags = a set of #GFileCreateFlags 621 * ioPriority = the [I/O priority][io-priority] of the request 622 * cancellable = optional #GCancellable object, 623 * %NULL to ignore 624 * callback = a #GAsyncReadyCallback to call 625 * when the request is satisfied 626 * userData = the data to pass to callback function 627 * 628 * Since: 2.22 629 */ 630 public void createReadwriteAsync(GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 631 { 632 g_file_create_readwrite_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 633 } 634 635 /** 636 * Finishes an asynchronous file create operation started with 637 * g_file_create_readwrite_async(). 638 * 639 * Params: 640 * res = a #GAsyncResult 641 * 642 * Returns: a #GFileIOStream or %NULL on error. 643 * Free the returned object with g_object_unref(). 644 * 645 * Since: 2.22 646 * 647 * Throws: GException on failure. 648 */ 649 public FileIOStream createReadwriteFinish(AsyncResultIF res) 650 { 651 GError* err = null; 652 653 auto __p = g_file_create_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 654 655 if (err !is null) 656 { 657 throw new GException( new ErrorG(err) ); 658 } 659 660 if(__p is null) 661 { 662 return null; 663 } 664 665 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) __p, true); 666 } 667 668 alias delet = delete_; 669 /** 670 * Deletes a file. If the @file is a directory, it will only be 671 * deleted if it is empty. This has the same semantics as g_unlink(). 672 * 673 * If @file doesn’t exist, %G_IO_ERROR_NOT_FOUND will be returned. This allows 674 * for deletion to be implemented avoiding 675 * [time-of-check to time-of-use races](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use): 676 * |[ 677 * g_autoptr(GError) local_error = NULL; 678 * if (!g_file_delete (my_file, my_cancellable, &local_error) && 679 * !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) 680 * { 681 * // deletion failed for some reason other than the file not existing: 682 * // so report the error 683 * g_warning ("Failed to delete %s: %s", 684 * g_file_peek_path (my_file), local_error->message); 685 * } 686 * ]| 687 * 688 * If @cancellable is not %NULL, then the operation can be cancelled by 689 * triggering the cancellable object from another thread. If the operation 690 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 691 * 692 * Params: 693 * cancellable = optional #GCancellable object, 694 * %NULL to ignore 695 * 696 * Returns: %TRUE if the file was deleted. %FALSE otherwise. 697 * 698 * Throws: GException on failure. 699 */ 700 public bool delete_(Cancellable cancellable) 701 { 702 GError* err = null; 703 704 auto __p = g_file_delete(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 705 706 if (err !is null) 707 { 708 throw new GException( new ErrorG(err) ); 709 } 710 711 return __p; 712 } 713 714 /** 715 * Asynchronously delete a file. If the @file is a directory, it will 716 * only be deleted if it is empty. This has the same semantics as 717 * g_unlink(). 718 * 719 * Params: 720 * ioPriority = the [I/O priority][io-priority] of the request 721 * cancellable = optional #GCancellable object, 722 * %NULL to ignore 723 * callback = a #GAsyncReadyCallback to call 724 * when the request is satisfied 725 * userData = the data to pass to callback function 726 * 727 * Since: 2.34 728 */ 729 public void deleteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 730 { 731 g_file_delete_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 732 } 733 734 /** 735 * Finishes deleting a file started with g_file_delete_async(). 736 * 737 * Params: 738 * result = a #GAsyncResult 739 * 740 * Returns: %TRUE if the file was deleted. %FALSE otherwise. 741 * 742 * Since: 2.34 743 * 744 * Throws: GException on failure. 745 */ 746 public bool deleteFinish(AsyncResultIF result) 747 { 748 GError* err = null; 749 750 auto __p = g_file_delete_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 751 752 if (err !is null) 753 { 754 throw new GException( new ErrorG(err) ); 755 } 756 757 return __p; 758 } 759 760 /** 761 * Duplicates a #GFile handle. This operation does not duplicate 762 * the actual file or directory represented by the #GFile; see 763 * g_file_copy() if attempting to copy a file. 764 * 765 * g_file_dup() is useful when a second handle is needed to the same underlying 766 * file, for use in a separate thread (#GFile is not thread-safe). For use 767 * within the same thread, use g_object_ref() to increment the existing object’s 768 * reference count. 769 * 770 * This call does no blocking I/O. 771 * 772 * Returns: a new #GFile that is a duplicate 773 * of the given #GFile. 774 */ 775 public FileIF dup() 776 { 777 auto __p = g_file_dup(getFileStruct()); 778 779 if(__p is null) 780 { 781 return null; 782 } 783 784 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 785 } 786 787 /** 788 * Starts an asynchronous eject on a mountable. 789 * When this operation has completed, @callback will be called with 790 * @user_user data, and the operation can be finalized with 791 * g_file_eject_mountable_finish(). 792 * 793 * If @cancellable is not %NULL, then the operation can be cancelled by 794 * triggering the cancellable object from another thread. If the operation 795 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 796 * 797 * Deprecated: Use g_file_eject_mountable_with_operation() instead. 798 * 799 * Params: 800 * flags = flags affecting the operation 801 * cancellable = optional #GCancellable object, 802 * %NULL to ignore 803 * callback = a #GAsyncReadyCallback to call 804 * when the request is satisfied, or %NULL 805 * userData = the data to pass to callback function 806 */ 807 public void ejectMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 808 { 809 g_file_eject_mountable(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 810 } 811 812 /** 813 * Finishes an asynchronous eject operation started by 814 * g_file_eject_mountable(). 815 * 816 * Deprecated: Use g_file_eject_mountable_with_operation_finish() 817 * instead. 818 * 819 * Params: 820 * result = a #GAsyncResult 821 * 822 * Returns: %TRUE if the @file was ejected successfully. 823 * %FALSE otherwise. 824 * 825 * Throws: GException on failure. 826 */ 827 public bool ejectMountableFinish(AsyncResultIF result) 828 { 829 GError* err = null; 830 831 auto __p = g_file_eject_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 832 833 if (err !is null) 834 { 835 throw new GException( new ErrorG(err) ); 836 } 837 838 return __p; 839 } 840 841 /** 842 * Starts an asynchronous eject on a mountable. 843 * When this operation has completed, @callback will be called with 844 * @user_user data, and the operation can be finalized with 845 * g_file_eject_mountable_with_operation_finish(). 846 * 847 * If @cancellable is not %NULL, then the operation can be cancelled by 848 * triggering the cancellable object from another thread. If the operation 849 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 850 * 851 * Params: 852 * flags = flags affecting the operation 853 * mountOperation = a #GMountOperation, 854 * or %NULL to avoid user interaction 855 * cancellable = optional #GCancellable object, 856 * %NULL to ignore 857 * callback = a #GAsyncReadyCallback to call 858 * when the request is satisfied, or %NULL 859 * userData = the data to pass to callback function 860 * 861 * Since: 2.22 862 */ 863 public void ejectMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 864 { 865 g_file_eject_mountable_with_operation(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 866 } 867 868 /** 869 * Finishes an asynchronous eject operation started by 870 * g_file_eject_mountable_with_operation(). 871 * 872 * Params: 873 * result = a #GAsyncResult 874 * 875 * Returns: %TRUE if the @file was ejected successfully. 876 * %FALSE otherwise. 877 * 878 * Since: 2.22 879 * 880 * Throws: GException on failure. 881 */ 882 public bool ejectMountableWithOperationFinish(AsyncResultIF result) 883 { 884 GError* err = null; 885 886 auto __p = g_file_eject_mountable_with_operation_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 887 888 if (err !is null) 889 { 890 throw new GException( new ErrorG(err) ); 891 } 892 893 return __p; 894 } 895 896 /** 897 * Gets the requested information about the files in a directory. 898 * The result is a #GFileEnumerator object that will give out 899 * #GFileInfo objects for all the files in the directory. 900 * 901 * The @attributes value is a string that specifies the file 902 * attributes that should be gathered. It is not an error if 903 * it's not possible to read a particular requested attribute 904 * from a file - it just won't be set. @attributes should 905 * be a comma-separated list of attributes or attribute wildcards. 906 * The wildcard "*" means all attributes, and a wildcard like 907 * "standard::*" means all attributes in the standard namespace. 908 * An example attribute query be "standard::*,owner::user". 909 * The standard attributes are available as defines, like 910 * %G_FILE_ATTRIBUTE_STANDARD_NAME. %G_FILE_ATTRIBUTE_STANDARD_NAME should 911 * always be specified if you plan to call g_file_enumerator_get_child() or 912 * g_file_enumerator_iterate() on the returned enumerator. 913 * 914 * If @cancellable is not %NULL, then the operation can be cancelled 915 * by triggering the cancellable object from another thread. If the 916 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 917 * returned. 918 * 919 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 920 * be returned. If the file is not a directory, the %G_IO_ERROR_NOT_DIRECTORY 921 * error will be returned. Other errors are possible too. 922 * 923 * Params: 924 * attributes = an attribute query string 925 * flags = a set of #GFileQueryInfoFlags 926 * cancellable = optional #GCancellable object, 927 * %NULL to ignore 928 * 929 * Returns: A #GFileEnumerator if successful, 930 * %NULL on error. Free the returned object with g_object_unref(). 931 * 932 * Throws: GException on failure. 933 */ 934 public FileEnumerator enumerateChildren(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable) 935 { 936 GError* err = null; 937 938 auto __p = g_file_enumerate_children(getFileStruct(), Str.toStringz(attributes), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 939 940 if (err !is null) 941 { 942 throw new GException( new ErrorG(err) ); 943 } 944 945 if(__p is null) 946 { 947 return null; 948 } 949 950 return ObjectG.getDObject!(FileEnumerator)(cast(GFileEnumerator*) __p, true); 951 } 952 953 /** 954 * Asynchronously gets the requested information about the files 955 * in a directory. The result is a #GFileEnumerator object that will 956 * give out #GFileInfo objects for all the files in the directory. 957 * 958 * For more details, see g_file_enumerate_children() which is 959 * the synchronous version of this call. 960 * 961 * When the operation is finished, @callback will be called. You can 962 * then call g_file_enumerate_children_finish() to get the result of 963 * the operation. 964 * 965 * Params: 966 * attributes = an attribute query string 967 * flags = a set of #GFileQueryInfoFlags 968 * ioPriority = the [I/O priority][io-priority] of the request 969 * cancellable = optional #GCancellable object, 970 * %NULL to ignore 971 * callback = a #GAsyncReadyCallback to call when the 972 * request is satisfied 973 * userData = the data to pass to callback function 974 */ 975 public void enumerateChildrenAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 976 { 977 g_file_enumerate_children_async(getFileStruct(), Str.toStringz(attributes), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 978 } 979 980 /** 981 * Finishes an async enumerate children operation. 982 * See g_file_enumerate_children_async(). 983 * 984 * Params: 985 * res = a #GAsyncResult 986 * 987 * Returns: a #GFileEnumerator or %NULL 988 * if an error occurred. 989 * Free the returned object with g_object_unref(). 990 * 991 * Throws: GException on failure. 992 */ 993 public FileEnumerator enumerateChildrenFinish(AsyncResultIF res) 994 { 995 GError* err = null; 996 997 auto __p = g_file_enumerate_children_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 998 999 if (err !is null) 1000 { 1001 throw new GException( new ErrorG(err) ); 1002 } 1003 1004 if(__p is null) 1005 { 1006 return null; 1007 } 1008 1009 return ObjectG.getDObject!(FileEnumerator)(cast(GFileEnumerator*) __p, true); 1010 } 1011 1012 /** 1013 * Checks if the two given #GFiles refer to the same file. 1014 * 1015 * Note that two #GFiles that differ can still refer to the same 1016 * file on the filesystem due to various forms of filename 1017 * aliasing. 1018 * 1019 * This call does no blocking I/O. 1020 * 1021 * Params: 1022 * file2 = the second #GFile 1023 * 1024 * Returns: %TRUE if @file1 and @file2 are equal. 1025 */ 1026 public bool equal(FileIF file2) 1027 { 1028 return g_file_equal(getFileStruct(), (file2 is null) ? null : file2.getFileStruct()) != 0; 1029 } 1030 1031 /** 1032 * Gets a #GMount for the #GFile. 1033 * 1034 * #GMount is returned only for user interesting locations, see 1035 * #GVolumeMonitor. If the #GFileIface for @file does not have a #mount, 1036 * @error will be set to %G_IO_ERROR_NOT_FOUND and %NULL #will be returned. 1037 * 1038 * If @cancellable is not %NULL, then the operation can be cancelled by 1039 * triggering the cancellable object from another thread. If the operation 1040 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1041 * 1042 * Params: 1043 * cancellable = optional #GCancellable object, 1044 * %NULL to ignore 1045 * 1046 * Returns: a #GMount where the @file is located 1047 * or %NULL on error. 1048 * Free the returned object with g_object_unref(). 1049 * 1050 * Throws: GException on failure. 1051 */ 1052 public MountIF findEnclosingMount(Cancellable cancellable) 1053 { 1054 GError* err = null; 1055 1056 auto __p = g_file_find_enclosing_mount(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 1057 1058 if (err !is null) 1059 { 1060 throw new GException( new ErrorG(err) ); 1061 } 1062 1063 if(__p is null) 1064 { 1065 return null; 1066 } 1067 1068 return ObjectG.getDObject!(MountIF)(cast(GMount*) __p, true); 1069 } 1070 1071 /** 1072 * Asynchronously gets the mount for the file. 1073 * 1074 * For more details, see g_file_find_enclosing_mount() which is 1075 * the synchronous version of this call. 1076 * 1077 * When the operation is finished, @callback will be called. 1078 * You can then call g_file_find_enclosing_mount_finish() to 1079 * get the result of the operation. 1080 * 1081 * Params: 1082 * ioPriority = the [I/O priority][io-priority] of the request 1083 * cancellable = optional #GCancellable object, 1084 * %NULL to ignore 1085 * callback = a #GAsyncReadyCallback to call 1086 * when the request is satisfied 1087 * userData = the data to pass to callback function 1088 */ 1089 public void findEnclosingMountAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1090 { 1091 g_file_find_enclosing_mount_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1092 } 1093 1094 /** 1095 * Finishes an asynchronous find mount request. 1096 * See g_file_find_enclosing_mount_async(). 1097 * 1098 * Params: 1099 * res = a #GAsyncResult 1100 * 1101 * Returns: #GMount for given @file or %NULL on error. 1102 * Free the returned object with g_object_unref(). 1103 * 1104 * Throws: GException on failure. 1105 */ 1106 public MountIF findEnclosingMountFinish(AsyncResultIF res) 1107 { 1108 GError* err = null; 1109 1110 auto __p = g_file_find_enclosing_mount_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 1111 1112 if (err !is null) 1113 { 1114 throw new GException( new ErrorG(err) ); 1115 } 1116 1117 if(__p is null) 1118 { 1119 return null; 1120 } 1121 1122 return ObjectG.getDObject!(MountIF)(cast(GMount*) __p, true); 1123 } 1124 1125 /** 1126 * Gets the base name (the last component of the path) for a given #GFile. 1127 * 1128 * If called for the top level of a system (such as the filesystem root 1129 * or a uri like sftp://host/) it will return a single directory separator 1130 * (and on Windows, possibly a drive letter). 1131 * 1132 * The base name is a byte string (not UTF-8). It has no defined encoding 1133 * or rules other than it may not contain zero bytes. If you want to use 1134 * filenames in a user interface you should use the display name that you 1135 * can get by requesting the %G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME 1136 * attribute with g_file_query_info(). 1137 * 1138 * This call does no blocking I/O. 1139 * 1140 * Returns: string containing the #GFile's 1141 * base name, or %NULL if given #GFile is invalid. The returned string 1142 * should be freed with g_free() when no longer needed. 1143 */ 1144 public string getBasename() 1145 { 1146 auto retStr = g_file_get_basename(getFileStruct()); 1147 1148 scope(exit) Str.freeString(retStr); 1149 return Str.toString(retStr); 1150 } 1151 1152 /** 1153 * Gets a child of @file with basename equal to @name. 1154 * 1155 * Note that the file with that specific name might not exist, but 1156 * you can still have a #GFile that points to it. You can use this 1157 * for instance to create that file. 1158 * 1159 * This call does no blocking I/O. 1160 * 1161 * Params: 1162 * name = string containing the child's basename 1163 * 1164 * Returns: a #GFile to a child specified by @name. 1165 * Free the returned object with g_object_unref(). 1166 */ 1167 public FileIF getChild(string name) 1168 { 1169 auto __p = g_file_get_child(getFileStruct(), Str.toStringz(name)); 1170 1171 if(__p is null) 1172 { 1173 return null; 1174 } 1175 1176 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 1177 } 1178 1179 /** 1180 * Gets the child of @file for a given @display_name (i.e. a UTF-8 1181 * version of the name). If this function fails, it returns %NULL 1182 * and @error will be set. This is very useful when constructing a 1183 * #GFile for a new file and the user entered the filename in the 1184 * user interface, for instance when you select a directory and 1185 * type a filename in the file selector. 1186 * 1187 * This call does no blocking I/O. 1188 * 1189 * Params: 1190 * displayName = string to a possible child 1191 * 1192 * Returns: a #GFile to the specified child, or 1193 * %NULL if the display name couldn't be converted. 1194 * Free the returned object with g_object_unref(). 1195 * 1196 * Throws: GException on failure. 1197 */ 1198 public FileIF getChildForDisplayName(string displayName) 1199 { 1200 GError* err = null; 1201 1202 auto __p = g_file_get_child_for_display_name(getFileStruct(), Str.toStringz(displayName), &err); 1203 1204 if (err !is null) 1205 { 1206 throw new GException( new ErrorG(err) ); 1207 } 1208 1209 if(__p is null) 1210 { 1211 return null; 1212 } 1213 1214 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 1215 } 1216 1217 /** 1218 * Gets the parent directory for the @file. 1219 * If the @file represents the root directory of the 1220 * file system, then %NULL will be returned. 1221 * 1222 * This call does no blocking I/O. 1223 * 1224 * Returns: a #GFile structure to the 1225 * parent of the given #GFile or %NULL if there is no parent. Free 1226 * the returned object with g_object_unref(). 1227 */ 1228 public FileIF getParent() 1229 { 1230 auto __p = g_file_get_parent(getFileStruct()); 1231 1232 if(__p is null) 1233 { 1234 return null; 1235 } 1236 1237 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 1238 } 1239 1240 /** 1241 * Gets the parse name of the @file. 1242 * A parse name is a UTF-8 string that describes the 1243 * file such that one can get the #GFile back using 1244 * g_file_parse_name(). 1245 * 1246 * This is generally used to show the #GFile as a nice 1247 * full-pathname kind of string in a user interface, 1248 * like in a location entry. 1249 * 1250 * For local files with names that can safely be converted 1251 * to UTF-8 the pathname is used, otherwise the IRI is used 1252 * (a form of URI that allows UTF-8 characters unescaped). 1253 * 1254 * This call does no blocking I/O. 1255 * 1256 * Returns: a string containing the #GFile's parse name. 1257 * The returned string should be freed with g_free() 1258 * when no longer needed. 1259 */ 1260 public string getParseName() 1261 { 1262 auto retStr = g_file_get_parse_name(getFileStruct()); 1263 1264 scope(exit) Str.freeString(retStr); 1265 return Str.toString(retStr); 1266 } 1267 1268 /** 1269 * Gets the local pathname for #GFile, if one exists. If non-%NULL, this is 1270 * guaranteed to be an absolute, canonical path. It might contain symlinks. 1271 * 1272 * This call does no blocking I/O. 1273 * 1274 * Returns: string containing the #GFile's path, 1275 * or %NULL if no such path exists. The returned string should be freed 1276 * with g_free() when no longer needed. 1277 */ 1278 public string getPath() 1279 { 1280 auto retStr = g_file_get_path(getFileStruct()); 1281 1282 scope(exit) Str.freeString(retStr); 1283 return Str.toString(retStr); 1284 } 1285 1286 /** 1287 * Gets the path for @descendant relative to @parent. 1288 * 1289 * This call does no blocking I/O. 1290 * 1291 * Params: 1292 * descendant = input #GFile 1293 * 1294 * Returns: string with the relative path from 1295 * @descendant to @parent, or %NULL if @descendant doesn't have @parent as 1296 * prefix. The returned string should be freed with g_free() when 1297 * no longer needed. 1298 */ 1299 public string getRelativePath(FileIF descendant) 1300 { 1301 auto retStr = g_file_get_relative_path(getFileStruct(), (descendant is null) ? null : descendant.getFileStruct()); 1302 1303 scope(exit) Str.freeString(retStr); 1304 return Str.toString(retStr); 1305 } 1306 1307 /** 1308 * Gets the URI for the @file. 1309 * 1310 * This call does no blocking I/O. 1311 * 1312 * Returns: a string containing the #GFile's URI. If the #GFile was constructed 1313 * with an invalid URI, an invalid URI is returned. 1314 * The returned string should be freed with g_free() 1315 * when no longer needed. 1316 */ 1317 public string getUri() 1318 { 1319 auto retStr = g_file_get_uri(getFileStruct()); 1320 1321 scope(exit) Str.freeString(retStr); 1322 return Str.toString(retStr); 1323 } 1324 1325 /** 1326 * Gets the URI scheme for a #GFile. 1327 * RFC 3986 decodes the scheme as: 1328 * |[ 1329 * URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ] 1330 * ]| 1331 * Common schemes include "file", "http", "ftp", etc. 1332 * 1333 * The scheme can be different from the one used to construct the #GFile, 1334 * in that it might be replaced with one that is logically equivalent to the #GFile. 1335 * 1336 * This call does no blocking I/O. 1337 * 1338 * Returns: a string containing the URI scheme for the given 1339 * #GFile or %NULL if the #GFile was constructed with an invalid URI. The 1340 * returned string should be freed with g_free() when no longer needed. 1341 */ 1342 public string getUriScheme() 1343 { 1344 auto retStr = g_file_get_uri_scheme(getFileStruct()); 1345 1346 scope(exit) Str.freeString(retStr); 1347 return Str.toString(retStr); 1348 } 1349 1350 /** 1351 * Checks if @file has a parent, and optionally, if it is @parent. 1352 * 1353 * If @parent is %NULL then this function returns %TRUE if @file has any 1354 * parent at all. If @parent is non-%NULL then %TRUE is only returned 1355 * if @file is an immediate child of @parent. 1356 * 1357 * Params: 1358 * parent = the parent to check for, or %NULL 1359 * 1360 * Returns: %TRUE if @file is an immediate child of @parent (or any parent in 1361 * the case that @parent is %NULL). 1362 * 1363 * Since: 2.24 1364 */ 1365 public bool hasParent(FileIF parent) 1366 { 1367 return g_file_has_parent(getFileStruct(), (parent is null) ? null : parent.getFileStruct()) != 0; 1368 } 1369 1370 /** 1371 * Checks whether @file has the prefix specified by @prefix. 1372 * 1373 * In other words, if the names of initial elements of @file's 1374 * pathname match @prefix. Only full pathname elements are matched, 1375 * so a path like /foo is not considered a prefix of /foobar, only 1376 * of /foo/bar. 1377 * 1378 * A #GFile is not a prefix of itself. If you want to check for 1379 * equality, use g_file_equal(). 1380 * 1381 * This call does no I/O, as it works purely on names. As such it can 1382 * sometimes return %FALSE even if @file is inside a @prefix (from a 1383 * filesystem point of view), because the prefix of @file is an alias 1384 * of @prefix. 1385 * 1386 * Params: 1387 * prefix = input #GFile 1388 * 1389 * Returns: %TRUE if the @file's parent, grandparent, etc is @prefix, 1390 * %FALSE otherwise. 1391 */ 1392 public bool hasPrefix(FileIF prefix) 1393 { 1394 return g_file_has_prefix(getFileStruct(), (prefix is null) ? null : prefix.getFileStruct()) != 0; 1395 } 1396 1397 /** 1398 * Checks to see if a #GFile has a given URI scheme. 1399 * 1400 * This call does no blocking I/O. 1401 * 1402 * Params: 1403 * uriScheme = a string containing a URI scheme 1404 * 1405 * Returns: %TRUE if #GFile's backend supports the 1406 * given URI scheme, %FALSE if URI scheme is %NULL, 1407 * not supported, or #GFile is invalid. 1408 */ 1409 public bool hasUriScheme(string uriScheme) 1410 { 1411 return g_file_has_uri_scheme(getFileStruct(), Str.toStringz(uriScheme)) != 0; 1412 } 1413 1414 /** 1415 * Creates a hash value for a #GFile. 1416 * 1417 * This call does no blocking I/O. 1418 * 1419 * Returns: 0 if @file is not a valid #GFile, otherwise an 1420 * integer that can be used as hash value for the #GFile. 1421 * This function is intended for easily hashing a #GFile to 1422 * add to a #GHashTable or similar data structure. 1423 */ 1424 public uint hash() 1425 { 1426 return g_file_hash(getFileStruct()); 1427 } 1428 1429 /** 1430 * Checks to see if a file is native to the platform. 1431 * 1432 * A native file is one expressed in the platform-native filename format, 1433 * e.g. "C:\Windows" or "/usr/bin/". This does not mean the file is local, 1434 * as it might be on a locally mounted remote filesystem. 1435 * 1436 * On some systems non-native files may be available using the native 1437 * filesystem via a userspace filesystem (FUSE), in these cases this call 1438 * will return %FALSE, but g_file_get_path() will still return a native path. 1439 * 1440 * This call does no blocking I/O. 1441 * 1442 * Returns: %TRUE if @file is native 1443 */ 1444 public bool isNative() 1445 { 1446 return g_file_is_native(getFileStruct()) != 0; 1447 } 1448 1449 /** 1450 * Loads the contents of @file and returns it as #GBytes. 1451 * 1452 * If @file is a resource:// based URI, the resulting bytes will reference the 1453 * embedded resource instead of a copy. Otherwise, this is equivalent to calling 1454 * g_file_load_contents() and g_bytes_new_take(). 1455 * 1456 * For resources, @etag_out will be set to %NULL. 1457 * 1458 * The data contained in the resulting #GBytes is always zero-terminated, but 1459 * this is not included in the #GBytes length. The resulting #GBytes should be 1460 * freed with g_bytes_unref() when no longer in use. 1461 * 1462 * Params: 1463 * cancellable = a #GCancellable or %NULL 1464 * etagOut = a location to place the current 1465 * entity tag for the file, or %NULL if the entity tag is not needed 1466 * 1467 * Returns: a #GBytes or %NULL and @error is set 1468 * 1469 * Since: 2.56 1470 * 1471 * Throws: GException on failure. 1472 */ 1473 public Bytes loadBytes(Cancellable cancellable, out string etagOut) 1474 { 1475 char* outetagOut = null; 1476 GError* err = null; 1477 1478 auto __p = g_file_load_bytes(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outetagOut, &err); 1479 1480 if (err !is null) 1481 { 1482 throw new GException( new ErrorG(err) ); 1483 } 1484 1485 etagOut = Str.toString(outetagOut); 1486 1487 if(__p is null) 1488 { 1489 return null; 1490 } 1491 1492 return new Bytes(cast(GBytes*) __p, true); 1493 } 1494 1495 /** 1496 * Asynchronously loads the contents of @file as #GBytes. 1497 * 1498 * If @file is a resource:// based URI, the resulting bytes will reference the 1499 * embedded resource instead of a copy. Otherwise, this is equivalent to calling 1500 * g_file_load_contents_async() and g_bytes_new_take(). 1501 * 1502 * @callback should call g_file_load_bytes_finish() to get the result of this 1503 * asynchronous operation. 1504 * 1505 * See g_file_load_bytes() for more information. 1506 * 1507 * Params: 1508 * cancellable = a #GCancellable or %NULL 1509 * callback = a #GAsyncReadyCallback to call when the 1510 * request is satisfied 1511 * userData = the data to pass to callback function 1512 * 1513 * Since: 2.56 1514 */ 1515 public void loadBytesAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1516 { 1517 g_file_load_bytes_async(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1518 } 1519 1520 /** 1521 * Completes an asynchronous request to g_file_load_bytes_async(). 1522 * 1523 * For resources, @etag_out will be set to %NULL. 1524 * 1525 * The data contained in the resulting #GBytes is always zero-terminated, but 1526 * this is not included in the #GBytes length. The resulting #GBytes should be 1527 * freed with g_bytes_unref() when no longer in use. 1528 * 1529 * See g_file_load_bytes() for more information. 1530 * 1531 * Params: 1532 * result = a #GAsyncResult provided to the callback 1533 * etagOut = a location to place the current 1534 * entity tag for the file, or %NULL if the entity tag is not needed 1535 * 1536 * Returns: a #GBytes or %NULL and @error is set 1537 * 1538 * Since: 2.56 1539 * 1540 * Throws: GException on failure. 1541 */ 1542 public Bytes loadBytesFinish(AsyncResultIF result, out string etagOut) 1543 { 1544 char* outetagOut = null; 1545 GError* err = null; 1546 1547 auto __p = g_file_load_bytes_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &outetagOut, &err); 1548 1549 if (err !is null) 1550 { 1551 throw new GException( new ErrorG(err) ); 1552 } 1553 1554 etagOut = Str.toString(outetagOut); 1555 1556 if(__p is null) 1557 { 1558 return null; 1559 } 1560 1561 return new Bytes(cast(GBytes*) __p, true); 1562 } 1563 1564 /** 1565 * Loads the content of the file into memory. The data is always 1566 * zero-terminated, but this is not included in the resultant @length. 1567 * The returned @contents should be freed with g_free() when no longer 1568 * needed. 1569 * 1570 * If @cancellable is not %NULL, then the operation can be cancelled by 1571 * triggering the cancellable object from another thread. If the operation 1572 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1573 * 1574 * Params: 1575 * cancellable = optional #GCancellable object, %NULL to ignore 1576 * contents = a location to place the contents of the file 1577 * etagOut = a location to place the current entity tag for the file, 1578 * or %NULL if the entity tag is not needed 1579 * 1580 * Returns: %TRUE if the @file's contents were successfully loaded. 1581 * %FALSE if there were errors. 1582 * 1583 * Throws: GException on failure. 1584 */ 1585 public bool loadContents(Cancellable cancellable, out string contents, out string etagOut) 1586 { 1587 char* outcontents = null; 1588 size_t length; 1589 char* outetagOut = null; 1590 GError* err = null; 1591 1592 auto __p = g_file_load_contents(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &outcontents, &length, &outetagOut, &err) != 0; 1593 1594 if (err !is null) 1595 { 1596 throw new GException( new ErrorG(err) ); 1597 } 1598 1599 contents = Str.toString(outcontents, length); 1600 etagOut = Str.toString(outetagOut); 1601 1602 return __p; 1603 } 1604 1605 /** 1606 * Starts an asynchronous load of the @file's contents. 1607 * 1608 * For more details, see g_file_load_contents() which is 1609 * the synchronous version of this call. 1610 * 1611 * When the load operation has completed, @callback will be called 1612 * with @user data. To finish the operation, call 1613 * g_file_load_contents_finish() with the #GAsyncResult returned by 1614 * the @callback. 1615 * 1616 * If @cancellable is not %NULL, then the operation can be cancelled by 1617 * triggering the cancellable object from another thread. If the operation 1618 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1619 * 1620 * Params: 1621 * cancellable = optional #GCancellable object, %NULL to ignore 1622 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1623 * userData = the data to pass to callback function 1624 */ 1625 public void loadContentsAsync(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1626 { 1627 g_file_load_contents_async(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1628 } 1629 1630 /** 1631 * Finishes an asynchronous load of the @file's contents. 1632 * The contents are placed in @contents, and @length is set to the 1633 * size of the @contents string. The @contents should be freed with 1634 * g_free() when no longer needed. If @etag_out is present, it will be 1635 * set to the new entity tag for the @file. 1636 * 1637 * Params: 1638 * res = a #GAsyncResult 1639 * contents = a location to place the contents of the file 1640 * etagOut = a location to place the current entity tag for the file, 1641 * or %NULL if the entity tag is not needed 1642 * 1643 * Returns: %TRUE if the load was successful. If %FALSE and @error is 1644 * present, it will be set appropriately. 1645 * 1646 * Throws: GException on failure. 1647 */ 1648 public bool loadContentsFinish(AsyncResultIF res, out string contents, out string etagOut) 1649 { 1650 char* outcontents = null; 1651 size_t length; 1652 char* outetagOut = null; 1653 GError* err = null; 1654 1655 auto __p = g_file_load_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outcontents, &length, &outetagOut, &err) != 0; 1656 1657 if (err !is null) 1658 { 1659 throw new GException( new ErrorG(err) ); 1660 } 1661 1662 contents = Str.toString(outcontents, length); 1663 etagOut = Str.toString(outetagOut); 1664 1665 return __p; 1666 } 1667 1668 /** 1669 * Reads the partial contents of a file. A #GFileReadMoreCallback should 1670 * be used to stop reading from the file when appropriate, else this 1671 * function will behave exactly as g_file_load_contents_async(). This 1672 * operation can be finished by g_file_load_partial_contents_finish(). 1673 * 1674 * Users of this function should be aware that @user_data is passed to 1675 * both the @read_more_callback and the @callback. 1676 * 1677 * If @cancellable is not %NULL, then the operation can be cancelled by 1678 * triggering the cancellable object from another thread. If the operation 1679 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1680 * 1681 * Params: 1682 * cancellable = optional #GCancellable object, %NULL to ignore 1683 * readMoreCallback = a 1684 * #GFileReadMoreCallback to receive partial data 1685 * and to specify whether further data should be read 1686 * callback = a #GAsyncReadyCallback to call 1687 * when the request is satisfied 1688 * userData = the data to pass to the callback functions 1689 */ 1690 public void loadPartialContentsAsync(Cancellable cancellable, GFileReadMoreCallback readMoreCallback, GAsyncReadyCallback callback, void* userData) 1691 { 1692 g_file_load_partial_contents_async(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), readMoreCallback, callback, userData); 1693 } 1694 1695 /** 1696 * Finishes an asynchronous partial load operation that was started 1697 * with g_file_load_partial_contents_async(). The data is always 1698 * zero-terminated, but this is not included in the resultant @length. 1699 * The returned @contents should be freed with g_free() when no longer 1700 * needed. 1701 * 1702 * Params: 1703 * res = a #GAsyncResult 1704 * contents = a location to place the contents of the file 1705 * etagOut = a location to place the current entity tag for the file, 1706 * or %NULL if the entity tag is not needed 1707 * 1708 * Returns: %TRUE if the load was successful. If %FALSE and @error is 1709 * present, it will be set appropriately. 1710 * 1711 * Throws: GException on failure. 1712 */ 1713 public bool loadPartialContentsFinish(AsyncResultIF res, out string contents, out string etagOut) 1714 { 1715 char* outcontents = null; 1716 size_t length; 1717 char* outetagOut = null; 1718 GError* err = null; 1719 1720 auto __p = g_file_load_partial_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outcontents, &length, &outetagOut, &err) != 0; 1721 1722 if (err !is null) 1723 { 1724 throw new GException( new ErrorG(err) ); 1725 } 1726 1727 contents = Str.toString(outcontents, length); 1728 etagOut = Str.toString(outetagOut); 1729 1730 return __p; 1731 } 1732 1733 /** 1734 * Creates a directory. Note that this will only create a child directory 1735 * of the immediate parent directory of the path or URI given by the #GFile. 1736 * To recursively create directories, see g_file_make_directory_with_parents(). 1737 * This function will fail if the parent directory does not exist, setting 1738 * @error to %G_IO_ERROR_NOT_FOUND. If the file system doesn't support 1739 * creating directories, this function will fail, setting @error to 1740 * %G_IO_ERROR_NOT_SUPPORTED. 1741 * 1742 * For a local #GFile the newly created directory will have the default 1743 * (current) ownership and permissions of the current process. 1744 * 1745 * If @cancellable is not %NULL, then the operation can be cancelled by 1746 * triggering the cancellable object from another thread. If the operation 1747 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1748 * 1749 * Params: 1750 * cancellable = optional #GCancellable object, 1751 * %NULL to ignore 1752 * 1753 * Returns: %TRUE on successful creation, %FALSE otherwise. 1754 * 1755 * Throws: GException on failure. 1756 */ 1757 public bool makeDirectory(Cancellable cancellable) 1758 { 1759 GError* err = null; 1760 1761 auto __p = g_file_make_directory(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1762 1763 if (err !is null) 1764 { 1765 throw new GException( new ErrorG(err) ); 1766 } 1767 1768 return __p; 1769 } 1770 1771 /** 1772 * Asynchronously creates a directory. 1773 * 1774 * Params: 1775 * ioPriority = the [I/O priority][io-priority] of the request 1776 * cancellable = optional #GCancellable object, 1777 * %NULL to ignore 1778 * callback = a #GAsyncReadyCallback to call 1779 * when the request is satisfied 1780 * userData = the data to pass to callback function 1781 * 1782 * Since: 2.38 1783 */ 1784 public void makeDirectoryAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1785 { 1786 g_file_make_directory_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1787 } 1788 1789 /** 1790 * Finishes an asynchronous directory creation, started with 1791 * g_file_make_directory_async(). 1792 * 1793 * Params: 1794 * result = a #GAsyncResult 1795 * 1796 * Returns: %TRUE on successful directory creation, %FALSE otherwise. 1797 * 1798 * Since: 2.38 1799 * 1800 * Throws: GException on failure. 1801 */ 1802 public bool makeDirectoryFinish(AsyncResultIF result) 1803 { 1804 GError* err = null; 1805 1806 auto __p = g_file_make_directory_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 1807 1808 if (err !is null) 1809 { 1810 throw new GException( new ErrorG(err) ); 1811 } 1812 1813 return __p; 1814 } 1815 1816 /** 1817 * Creates a directory and any parent directories that may not 1818 * exist similar to 'mkdir -p'. If the file system does not support 1819 * creating directories, this function will fail, setting @error to 1820 * %G_IO_ERROR_NOT_SUPPORTED. If the directory itself already exists, 1821 * this function will fail setting @error to %G_IO_ERROR_EXISTS, unlike 1822 * the similar g_mkdir_with_parents(). 1823 * 1824 * For a local #GFile the newly created directories will have the default 1825 * (current) ownership and permissions of the current process. 1826 * 1827 * If @cancellable is not %NULL, then the operation can be cancelled by 1828 * triggering the cancellable object from another thread. If the operation 1829 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1830 * 1831 * Params: 1832 * cancellable = optional #GCancellable object, 1833 * %NULL to ignore 1834 * 1835 * Returns: %TRUE if all directories have been successfully created, %FALSE 1836 * otherwise. 1837 * 1838 * Since: 2.18 1839 * 1840 * Throws: GException on failure. 1841 */ 1842 public bool makeDirectoryWithParents(Cancellable cancellable) 1843 { 1844 GError* err = null; 1845 1846 auto __p = g_file_make_directory_with_parents(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1847 1848 if (err !is null) 1849 { 1850 throw new GException( new ErrorG(err) ); 1851 } 1852 1853 return __p; 1854 } 1855 1856 /** 1857 * Creates a symbolic link named @file which contains the string 1858 * @symlink_value. 1859 * 1860 * If @cancellable is not %NULL, then the operation can be cancelled by 1861 * triggering the cancellable object from another thread. If the operation 1862 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1863 * 1864 * Params: 1865 * symlinkValue = a string with the path for the target 1866 * of the new symlink 1867 * cancellable = optional #GCancellable object, 1868 * %NULL to ignore 1869 * 1870 * Returns: %TRUE on the creation of a new symlink, %FALSE otherwise. 1871 * 1872 * Throws: GException on failure. 1873 */ 1874 public bool makeSymbolicLink(string symlinkValue, Cancellable cancellable) 1875 { 1876 GError* err = null; 1877 1878 auto __p = g_file_make_symbolic_link(getFileStruct(), Str.toStringz(symlinkValue), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 1879 1880 if (err !is null) 1881 { 1882 throw new GException( new ErrorG(err) ); 1883 } 1884 1885 return __p; 1886 } 1887 1888 /** 1889 * Recursively measures the disk usage of @file. 1890 * 1891 * This is essentially an analog of the 'du' command, but it also 1892 * reports the number of directories and non-directory files encountered 1893 * (including things like symbolic links). 1894 * 1895 * By default, errors are only reported against the toplevel file 1896 * itself. Errors found while recursing are silently ignored, unless 1897 * %G_FILE_MEASURE_REPORT_ANY_ERROR is given in @flags. 1898 * 1899 * The returned size, @disk_usage, is in bytes and should be formatted 1900 * with g_format_size() in order to get something reasonable for showing 1901 * in a user interface. 1902 * 1903 * @progress_callback and @progress_data can be given to request 1904 * periodic progress updates while scanning. See the documentation for 1905 * #GFileMeasureProgressCallback for information about when and how the 1906 * callback will be invoked. 1907 * 1908 * Params: 1909 * flags = #GFileMeasureFlags 1910 * cancellable = optional #GCancellable 1911 * progressCallback = a #GFileMeasureProgressCallback 1912 * progressData = user_data for @progress_callback 1913 * diskUsage = the number of bytes of disk space used 1914 * numDirs = the number of directories encountered 1915 * numFiles = the number of non-directories encountered 1916 * 1917 * Returns: %TRUE if successful, with the out parameters set. 1918 * %FALSE otherwise, with @error set. 1919 * 1920 * Since: 2.38 1921 * 1922 * Throws: GException on failure. 1923 */ 1924 public bool measureDiskUsage(GFileMeasureFlags flags, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, out ulong diskUsage, out ulong numDirs, out ulong numFiles) 1925 { 1926 GError* err = null; 1927 1928 auto __p = g_file_measure_disk_usage(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressData, &diskUsage, &numDirs, &numFiles, &err) != 0; 1929 1930 if (err !is null) 1931 { 1932 throw new GException( new ErrorG(err) ); 1933 } 1934 1935 return __p; 1936 } 1937 1938 /** 1939 * Recursively measures the disk usage of @file. 1940 * 1941 * This is the asynchronous version of g_file_measure_disk_usage(). See 1942 * there for more information. 1943 * 1944 * Params: 1945 * flags = #GFileMeasureFlags 1946 * ioPriority = the [I/O priority][io-priority] of the request 1947 * cancellable = optional #GCancellable 1948 * progressCallback = a #GFileMeasureProgressCallback 1949 * progressData = user_data for @progress_callback 1950 * callback = a #GAsyncReadyCallback to call when complete 1951 * userData = the data to pass to callback function 1952 * 1953 * Since: 2.38 1954 */ 1955 public void measureDiskUsageAsync(GFileMeasureFlags flags, int ioPriority, Cancellable cancellable, GFileMeasureProgressCallback progressCallback, void* progressData, GAsyncReadyCallback callback, void* userData) 1956 { 1957 g_file_measure_disk_usage_async(getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressData, callback, userData); 1958 } 1959 1960 /** 1961 * Collects the results from an earlier call to 1962 * g_file_measure_disk_usage_async(). See g_file_measure_disk_usage() for 1963 * more information. 1964 * 1965 * Params: 1966 * result = the #GAsyncResult passed to your #GAsyncReadyCallback 1967 * diskUsage = the number of bytes of disk space used 1968 * numDirs = the number of directories encountered 1969 * numFiles = the number of non-directories encountered 1970 * 1971 * Returns: %TRUE if successful, with the out parameters set. 1972 * %FALSE otherwise, with @error set. 1973 * 1974 * Since: 2.38 1975 * 1976 * Throws: GException on failure. 1977 */ 1978 public bool measureDiskUsageFinish(AsyncResultIF result, out ulong diskUsage, out ulong numDirs, out ulong numFiles) 1979 { 1980 GError* err = null; 1981 1982 auto __p = g_file_measure_disk_usage_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &diskUsage, &numDirs, &numFiles, &err) != 0; 1983 1984 if (err !is null) 1985 { 1986 throw new GException( new ErrorG(err) ); 1987 } 1988 1989 return __p; 1990 } 1991 1992 /** 1993 * Obtains a file or directory monitor for the given file, 1994 * depending on the type of the file. 1995 * 1996 * If @cancellable is not %NULL, then the operation can be cancelled by 1997 * triggering the cancellable object from another thread. If the operation 1998 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 1999 * 2000 * Params: 2001 * flags = a set of #GFileMonitorFlags 2002 * cancellable = optional #GCancellable object, 2003 * %NULL to ignore 2004 * 2005 * Returns: a #GFileMonitor for the given @file, 2006 * or %NULL on error. 2007 * Free the returned object with g_object_unref(). 2008 * 2009 * Since: 2.18 2010 * 2011 * Throws: GException on failure. 2012 */ 2013 public FileMonitor monitor(GFileMonitorFlags flags, Cancellable cancellable) 2014 { 2015 GError* err = null; 2016 2017 auto __p = g_file_monitor(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2018 2019 if (err !is null) 2020 { 2021 throw new GException( new ErrorG(err) ); 2022 } 2023 2024 if(__p is null) 2025 { 2026 return null; 2027 } 2028 2029 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) __p, true); 2030 } 2031 2032 /** 2033 * Obtains a directory monitor for the given file. 2034 * This may fail if directory monitoring is not supported. 2035 * 2036 * If @cancellable is not %NULL, then the operation can be cancelled by 2037 * triggering the cancellable object from another thread. If the operation 2038 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2039 * 2040 * It does not make sense for @flags to contain 2041 * %G_FILE_MONITOR_WATCH_HARD_LINKS, since hard links can not be made to 2042 * directories. It is not possible to monitor all the files in a 2043 * directory for changes made via hard links; if you want to do this then 2044 * you must register individual watches with g_file_monitor(). 2045 * 2046 * Params: 2047 * flags = a set of #GFileMonitorFlags 2048 * cancellable = optional #GCancellable object, 2049 * %NULL to ignore 2050 * 2051 * Returns: a #GFileMonitor for the given @file, 2052 * or %NULL on error. 2053 * Free the returned object with g_object_unref(). 2054 * 2055 * Throws: GException on failure. 2056 */ 2057 public FileMonitor monitorDirectory(GFileMonitorFlags flags, Cancellable cancellable) 2058 { 2059 GError* err = null; 2060 2061 auto __p = g_file_monitor_directory(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2062 2063 if (err !is null) 2064 { 2065 throw new GException( new ErrorG(err) ); 2066 } 2067 2068 if(__p is null) 2069 { 2070 return null; 2071 } 2072 2073 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) __p, true); 2074 } 2075 2076 /** 2077 * Obtains a file monitor for the given file. If no file notification 2078 * mechanism exists, then regular polling of the file is used. 2079 * 2080 * If @cancellable is not %NULL, then the operation can be cancelled by 2081 * triggering the cancellable object from another thread. If the operation 2082 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2083 * 2084 * If @flags contains %G_FILE_MONITOR_WATCH_HARD_LINKS then the monitor 2085 * will also attempt to report changes made to the file via another 2086 * filename (ie, a hard link). Without this flag, you can only rely on 2087 * changes made through the filename contained in @file to be 2088 * reported. Using this flag may result in an increase in resource 2089 * usage, and may not have any effect depending on the #GFileMonitor 2090 * backend and/or filesystem type. 2091 * 2092 * Params: 2093 * flags = a set of #GFileMonitorFlags 2094 * cancellable = optional #GCancellable object, 2095 * %NULL to ignore 2096 * 2097 * Returns: a #GFileMonitor for the given @file, 2098 * or %NULL on error. 2099 * Free the returned object with g_object_unref(). 2100 * 2101 * Throws: GException on failure. 2102 */ 2103 public FileMonitor monitorFile(GFileMonitorFlags flags, Cancellable cancellable) 2104 { 2105 GError* err = null; 2106 2107 auto __p = g_file_monitor_file(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2108 2109 if (err !is null) 2110 { 2111 throw new GException( new ErrorG(err) ); 2112 } 2113 2114 if(__p is null) 2115 { 2116 return null; 2117 } 2118 2119 return ObjectG.getDObject!(FileMonitor)(cast(GFileMonitor*) __p, true); 2120 } 2121 2122 /** 2123 * Starts a @mount_operation, mounting the volume that contains 2124 * the file @location. 2125 * 2126 * When this operation has completed, @callback will be called with 2127 * @user_user data, and the operation can be finalized with 2128 * g_file_mount_enclosing_volume_finish(). 2129 * 2130 * If @cancellable is not %NULL, then the operation can be cancelled by 2131 * triggering the cancellable object from another thread. If the operation 2132 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2133 * 2134 * Params: 2135 * flags = flags affecting the operation 2136 * mountOperation = a #GMountOperation 2137 * or %NULL to avoid user interaction 2138 * cancellable = optional #GCancellable object, 2139 * %NULL to ignore 2140 * callback = a #GAsyncReadyCallback to call 2141 * when the request is satisfied, or %NULL 2142 * userData = the data to pass to callback function 2143 */ 2144 public void mountEnclosingVolume(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2145 { 2146 g_file_mount_enclosing_volume(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2147 } 2148 2149 /** 2150 * Finishes a mount operation started by g_file_mount_enclosing_volume(). 2151 * 2152 * Params: 2153 * result = a #GAsyncResult 2154 * 2155 * Returns: %TRUE if successful. If an error has occurred, 2156 * this function will return %FALSE and set @error 2157 * appropriately if present. 2158 * 2159 * Throws: GException on failure. 2160 */ 2161 public bool mountEnclosingVolumeFinish(AsyncResultIF result) 2162 { 2163 GError* err = null; 2164 2165 auto __p = g_file_mount_enclosing_volume_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2166 2167 if (err !is null) 2168 { 2169 throw new GException( new ErrorG(err) ); 2170 } 2171 2172 return __p; 2173 } 2174 2175 /** 2176 * Mounts a file of type G_FILE_TYPE_MOUNTABLE. 2177 * Using @mount_operation, you can request callbacks when, for instance, 2178 * passwords are needed during authentication. 2179 * 2180 * If @cancellable is not %NULL, then the operation can be cancelled by 2181 * triggering the cancellable object from another thread. If the operation 2182 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2183 * 2184 * When the operation is finished, @callback will be called. 2185 * You can then call g_file_mount_mountable_finish() to get 2186 * the result of the operation. 2187 * 2188 * Params: 2189 * flags = flags affecting the operation 2190 * mountOperation = a #GMountOperation, 2191 * or %NULL to avoid user interaction 2192 * cancellable = optional #GCancellable object, 2193 * %NULL to ignore 2194 * callback = a #GAsyncReadyCallback to call 2195 * when the request is satisfied, or %NULL 2196 * userData = the data to pass to callback function 2197 */ 2198 public void mountMountable(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2199 { 2200 g_file_mount_mountable(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2201 } 2202 2203 /** 2204 * Finishes a mount operation. See g_file_mount_mountable() for details. 2205 * 2206 * Finish an asynchronous mount operation that was started 2207 * with g_file_mount_mountable(). 2208 * 2209 * Params: 2210 * result = a #GAsyncResult 2211 * 2212 * Returns: a #GFile or %NULL on error. 2213 * Free the returned object with g_object_unref(). 2214 * 2215 * Throws: GException on failure. 2216 */ 2217 public FileIF mountMountableFinish(AsyncResultIF result) 2218 { 2219 GError* err = null; 2220 2221 auto __p = g_file_mount_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 2222 2223 if (err !is null) 2224 { 2225 throw new GException( new ErrorG(err) ); 2226 } 2227 2228 if(__p is null) 2229 { 2230 return null; 2231 } 2232 2233 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 2234 } 2235 2236 /** 2237 * Tries to move the file or directory @source to the location specified 2238 * by @destination. If native move operations are supported then this is 2239 * used, otherwise a copy + delete fallback is used. The native 2240 * implementation may support moving directories (for instance on moves 2241 * inside the same filesystem), but the fallback code does not. 2242 * 2243 * If the flag %G_FILE_COPY_OVERWRITE is specified an already 2244 * existing @destination file is overwritten. 2245 * 2246 * If @cancellable is not %NULL, then the operation can be cancelled by 2247 * triggering the cancellable object from another thread. If the operation 2248 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2249 * 2250 * If @progress_callback is not %NULL, then the operation can be monitored 2251 * by setting this to a #GFileProgressCallback function. 2252 * @progress_callback_data will be passed to this function. It is 2253 * guaranteed that this callback will be called after all data has been 2254 * transferred with the total number of bytes copied during the operation. 2255 * 2256 * If the @source file does not exist, then the %G_IO_ERROR_NOT_FOUND 2257 * error is returned, independent on the status of the @destination. 2258 * 2259 * If %G_FILE_COPY_OVERWRITE is not specified and the target exists, 2260 * then the error %G_IO_ERROR_EXISTS is returned. 2261 * 2262 * If trying to overwrite a file over a directory, the %G_IO_ERROR_IS_DIRECTORY 2263 * error is returned. If trying to overwrite a directory with a directory the 2264 * %G_IO_ERROR_WOULD_MERGE error is returned. 2265 * 2266 * If the source is a directory and the target does not exist, or 2267 * %G_FILE_COPY_OVERWRITE is specified and the target is a file, then 2268 * the %G_IO_ERROR_WOULD_RECURSE error may be returned (if the native 2269 * move operation isn't available). 2270 * 2271 * Params: 2272 * destination = #GFile pointing to the destination location 2273 * flags = set of #GFileCopyFlags 2274 * cancellable = optional #GCancellable object, 2275 * %NULL to ignore 2276 * progressCallback = #GFileProgressCallback 2277 * function for updates 2278 * progressCallbackData = gpointer to user data for 2279 * the callback function 2280 * 2281 * Returns: %TRUE on successful move, %FALSE otherwise. 2282 * 2283 * Throws: GException on failure. 2284 */ 2285 public bool move(FileIF destination, GFileCopyFlags flags, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData) 2286 { 2287 GError* err = null; 2288 2289 auto __p = g_file_move(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, &err) != 0; 2290 2291 if (err !is null) 2292 { 2293 throw new GException( new ErrorG(err) ); 2294 } 2295 2296 return __p; 2297 } 2298 2299 /** 2300 * Asynchronously moves a file @source to the location of @destination. For details of the behaviour, see g_file_move(). 2301 * 2302 * If @progress_callback is not %NULL, then that function that will be called 2303 * just like in g_file_move(). The callback will run in the default main context 2304 * of the thread calling g_file_move_async() — the same context as @callback is 2305 * run in. 2306 * 2307 * When the operation is finished, @callback will be called. You can then call 2308 * g_file_move_finish() to get the result of the operation. 2309 * 2310 * Params: 2311 * destination = #GFile pointing to the destination location 2312 * flags = set of #GFileCopyFlags 2313 * ioPriority = the [I/O priority][io-priority] of the request 2314 * cancellable = optional #GCancellable object, 2315 * %NULL to ignore 2316 * progressCallback = #GFileProgressCallback 2317 * function for updates 2318 * progressCallbackData = gpointer to user data for 2319 * the callback function 2320 * callback = a #GAsyncReadyCallback to call 2321 * when the request is satisfied 2322 * userData = the data to pass to callback function 2323 * 2324 * Since: 2.72 2325 */ 2326 public void moveAsync(FileIF destination, GFileCopyFlags flags, int ioPriority, Cancellable cancellable, GFileProgressCallback progressCallback, void* progressCallbackData, GAsyncReadyCallback callback, void* userData) 2327 { 2328 g_file_move_async(getFileStruct(), (destination is null) ? null : destination.getFileStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), progressCallback, progressCallbackData, callback, userData); 2329 } 2330 2331 /** 2332 * Finishes an asynchronous file movement, started with 2333 * g_file_move_async(). 2334 * 2335 * Params: 2336 * result = a #GAsyncResult 2337 * 2338 * Returns: %TRUE on successful file move, %FALSE otherwise. 2339 * 2340 * Since: 2.72 2341 * 2342 * Throws: GException on failure. 2343 */ 2344 public bool moveFinish(AsyncResultIF result) 2345 { 2346 GError* err = null; 2347 2348 auto __p = g_file_move_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2349 2350 if (err !is null) 2351 { 2352 throw new GException( new ErrorG(err) ); 2353 } 2354 2355 return __p; 2356 } 2357 2358 /** 2359 * Opens an existing file for reading and writing. The result is 2360 * a #GFileIOStream that can be used to read and write the contents 2361 * of the file. 2362 * 2363 * If @cancellable is not %NULL, then the operation can be cancelled 2364 * by triggering the cancellable object from another thread. If the 2365 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2366 * returned. 2367 * 2368 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 2369 * be returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 2370 * error will be returned. Other errors are possible too, and depend on 2371 * what kind of filesystem the file is on. Note that in many non-local 2372 * file cases read and write streams are not supported, so make sure you 2373 * really need to do read and write streaming, rather than just opening 2374 * for reading or writing. 2375 * 2376 * Params: 2377 * cancellable = a #GCancellable 2378 * 2379 * Returns: #GFileIOStream or %NULL on error. 2380 * Free the returned object with g_object_unref(). 2381 * 2382 * Since: 2.22 2383 * 2384 * Throws: GException on failure. 2385 */ 2386 public FileIOStream openReadwrite(Cancellable cancellable) 2387 { 2388 GError* err = null; 2389 2390 auto __p = g_file_open_readwrite(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2391 2392 if (err !is null) 2393 { 2394 throw new GException( new ErrorG(err) ); 2395 } 2396 2397 if(__p is null) 2398 { 2399 return null; 2400 } 2401 2402 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) __p, true); 2403 } 2404 2405 /** 2406 * Asynchronously opens @file for reading and writing. 2407 * 2408 * For more details, see g_file_open_readwrite() which is 2409 * the synchronous version of this call. 2410 * 2411 * When the operation is finished, @callback will be called. 2412 * You can then call g_file_open_readwrite_finish() to get 2413 * the result of the operation. 2414 * 2415 * Params: 2416 * ioPriority = the [I/O priority][io-priority] of the request 2417 * cancellable = optional #GCancellable object, 2418 * %NULL to ignore 2419 * callback = a #GAsyncReadyCallback to call 2420 * when the request is satisfied 2421 * userData = the data to pass to callback function 2422 * 2423 * Since: 2.22 2424 */ 2425 public void openReadwriteAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2426 { 2427 g_file_open_readwrite_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2428 } 2429 2430 /** 2431 * Finishes an asynchronous file read operation started with 2432 * g_file_open_readwrite_async(). 2433 * 2434 * Params: 2435 * res = a #GAsyncResult 2436 * 2437 * Returns: a #GFileIOStream or %NULL on error. 2438 * Free the returned object with g_object_unref(). 2439 * 2440 * Since: 2.22 2441 * 2442 * Throws: GException on failure. 2443 */ 2444 public FileIOStream openReadwriteFinish(AsyncResultIF res) 2445 { 2446 GError* err = null; 2447 2448 auto __p = g_file_open_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2449 2450 if (err !is null) 2451 { 2452 throw new GException( new ErrorG(err) ); 2453 } 2454 2455 if(__p is null) 2456 { 2457 return null; 2458 } 2459 2460 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) __p, true); 2461 } 2462 2463 /** 2464 * Exactly like g_file_get_path(), but caches the result via 2465 * g_object_set_qdata_full(). This is useful for example in C 2466 * applications which mix `g_file_*` APIs with native ones. It 2467 * also avoids an extra duplicated string when possible, so will be 2468 * generally more efficient. 2469 * 2470 * This call does no blocking I/O. 2471 * 2472 * Returns: string containing the #GFile's path, 2473 * or %NULL if no such path exists. The returned string is owned by @file. 2474 * 2475 * Since: 2.56 2476 */ 2477 public string peekPath() 2478 { 2479 return Str.toString(g_file_peek_path(getFileStruct())); 2480 } 2481 2482 /** 2483 * Polls a file of type %G_FILE_TYPE_MOUNTABLE. 2484 * 2485 * If @cancellable is not %NULL, then the operation can be cancelled by 2486 * triggering the cancellable object from another thread. If the operation 2487 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2488 * 2489 * When the operation is finished, @callback will be called. 2490 * You can then call g_file_mount_mountable_finish() to get 2491 * the result of the operation. 2492 * 2493 * Params: 2494 * cancellable = optional #GCancellable object, %NULL to ignore 2495 * callback = a #GAsyncReadyCallback to call 2496 * when the request is satisfied, or %NULL 2497 * userData = the data to pass to callback function 2498 * 2499 * Since: 2.22 2500 */ 2501 public void pollMountable(Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2502 { 2503 g_file_poll_mountable(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2504 } 2505 2506 /** 2507 * Finishes a poll operation. See g_file_poll_mountable() for details. 2508 * 2509 * Finish an asynchronous poll operation that was polled 2510 * with g_file_poll_mountable(). 2511 * 2512 * Params: 2513 * result = a #GAsyncResult 2514 * 2515 * Returns: %TRUE if the operation finished successfully. %FALSE 2516 * otherwise. 2517 * 2518 * Since: 2.22 2519 * 2520 * Throws: GException on failure. 2521 */ 2522 public bool pollMountableFinish(AsyncResultIF result) 2523 { 2524 GError* err = null; 2525 2526 auto __p = g_file_poll_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 2527 2528 if (err !is null) 2529 { 2530 throw new GException( new ErrorG(err) ); 2531 } 2532 2533 return __p; 2534 } 2535 2536 /** 2537 * Returns the #GAppInfo that is registered as the default 2538 * application to handle the file specified by @file. 2539 * 2540 * If @cancellable is not %NULL, then the operation can be cancelled by 2541 * triggering the cancellable object from another thread. If the operation 2542 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2543 * 2544 * Params: 2545 * cancellable = optional #GCancellable object, %NULL to ignore 2546 * 2547 * Returns: a #GAppInfo if the handle was found, 2548 * %NULL if there were errors. 2549 * When you are done with it, release it with g_object_unref() 2550 * 2551 * Throws: GException on failure. 2552 */ 2553 public AppInfoIF queryDefaultHandler(Cancellable cancellable) 2554 { 2555 GError* err = null; 2556 2557 auto __p = g_file_query_default_handler(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2558 2559 if (err !is null) 2560 { 2561 throw new GException( new ErrorG(err) ); 2562 } 2563 2564 if(__p is null) 2565 { 2566 return null; 2567 } 2568 2569 return ObjectG.getDObject!(AppInfoIF)(cast(GAppInfo*) __p, true); 2570 } 2571 2572 /** 2573 * Async version of g_file_query_default_handler(). 2574 * 2575 * Params: 2576 * ioPriority = the [I/O priority][io-priority] of the request 2577 * cancellable = optional #GCancellable object, %NULL to ignore 2578 * callback = a #GAsyncReadyCallback to call when the request is done 2579 * userData = data to pass to @callback 2580 * 2581 * Since: 2.60 2582 */ 2583 public void queryDefaultHandlerAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2584 { 2585 g_file_query_default_handler_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2586 } 2587 2588 /** 2589 * Finishes a g_file_query_default_handler_async() operation. 2590 * 2591 * Params: 2592 * result = a #GAsyncResult 2593 * 2594 * Returns: a #GAppInfo if the handle was found, 2595 * %NULL if there were errors. 2596 * When you are done with it, release it with g_object_unref() 2597 * 2598 * Since: 2.60 2599 * 2600 * Throws: GException on failure. 2601 */ 2602 public AppInfoIF queryDefaultHandlerFinish(AsyncResultIF result) 2603 { 2604 GError* err = null; 2605 2606 auto __p = g_file_query_default_handler_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err); 2607 2608 if (err !is null) 2609 { 2610 throw new GException( new ErrorG(err) ); 2611 } 2612 2613 if(__p is null) 2614 { 2615 return null; 2616 } 2617 2618 return ObjectG.getDObject!(AppInfoIF)(cast(GAppInfo*) __p, true); 2619 } 2620 2621 /** 2622 * Utility function to check if a particular file exists. This is 2623 * implemented using g_file_query_info() and as such does blocking I/O. 2624 * 2625 * Note that in many cases it is [racy to first check for file existence](https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use) 2626 * and then execute something based on the outcome of that, because the 2627 * file might have been created or removed in between the operations. The 2628 * general approach to handling that is to not check, but just do the 2629 * operation and handle the errors as they come. 2630 * 2631 * As an example of race-free checking, take the case of reading a file, 2632 * and if it doesn't exist, creating it. There are two racy versions: read 2633 * it, and on error create it; and: check if it exists, if not create it. 2634 * These can both result in two processes creating the file (with perhaps 2635 * a partially written file as the result). The correct approach is to 2636 * always try to create the file with g_file_create() which will either 2637 * atomically create the file or fail with a %G_IO_ERROR_EXISTS error. 2638 * 2639 * However, in many cases an existence check is useful in a user interface, 2640 * for instance to make a menu item sensitive/insensitive, so that you don't 2641 * have to fool users that something is possible and then just show an error 2642 * dialog. If you do this, you should make sure to also handle the errors 2643 * that can happen due to races when you execute the operation. 2644 * 2645 * Params: 2646 * cancellable = optional #GCancellable object, 2647 * %NULL to ignore 2648 * 2649 * Returns: %TRUE if the file exists (and can be detected without error), 2650 * %FALSE otherwise (or if cancelled). 2651 */ 2652 public bool queryExists(Cancellable cancellable) 2653 { 2654 return g_file_query_exists(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct()) != 0; 2655 } 2656 2657 /** 2658 * Utility function to inspect the #GFileType of a file. This is 2659 * implemented using g_file_query_info() and as such does blocking I/O. 2660 * 2661 * The primary use case of this method is to check if a file is 2662 * a regular file, directory, or symlink. 2663 * 2664 * Params: 2665 * flags = a set of #GFileQueryInfoFlags passed to g_file_query_info() 2666 * cancellable = optional #GCancellable object, 2667 * %NULL to ignore 2668 * 2669 * Returns: The #GFileType of the file and %G_FILE_TYPE_UNKNOWN 2670 * if the file does not exist 2671 * 2672 * Since: 2.18 2673 */ 2674 public GFileType queryFileType(GFileQueryInfoFlags flags, Cancellable cancellable) 2675 { 2676 return g_file_query_file_type(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct()); 2677 } 2678 2679 /** 2680 * Similar to g_file_query_info(), but obtains information 2681 * about the filesystem the @file is on, rather than the file itself. 2682 * For instance the amount of space available and the type of 2683 * the filesystem. 2684 * 2685 * The @attributes value is a string that specifies the attributes 2686 * that should be gathered. It is not an error if it's not possible 2687 * to read a particular requested attribute from a file - it just 2688 * won't be set. @attributes should be a comma-separated list of 2689 * attributes or attribute wildcards. The wildcard "*" means all 2690 * attributes, and a wildcard like "filesystem::*" means all attributes 2691 * in the filesystem namespace. The standard namespace for filesystem 2692 * attributes is "filesystem". Common attributes of interest are 2693 * %G_FILE_ATTRIBUTE_FILESYSTEM_SIZE (the total size of the filesystem 2694 * in bytes), %G_FILE_ATTRIBUTE_FILESYSTEM_FREE (number of bytes available), 2695 * and %G_FILE_ATTRIBUTE_FILESYSTEM_TYPE (type of the filesystem). 2696 * 2697 * If @cancellable is not %NULL, then the operation can be cancelled 2698 * by triggering the cancellable object from another thread. If the 2699 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2700 * returned. 2701 * 2702 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will 2703 * be returned. Other errors are possible too, and depend on what 2704 * kind of filesystem the file is on. 2705 * 2706 * Params: 2707 * attributes = an attribute query string 2708 * cancellable = optional #GCancellable object, 2709 * %NULL to ignore 2710 * 2711 * Returns: a #GFileInfo or %NULL if there was an error. 2712 * Free the returned object with g_object_unref(). 2713 * 2714 * Throws: GException on failure. 2715 */ 2716 public FileInfo queryFilesystemInfo(string attributes, Cancellable cancellable) 2717 { 2718 GError* err = null; 2719 2720 auto __p = g_file_query_filesystem_info(getFileStruct(), Str.toStringz(attributes), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2721 2722 if (err !is null) 2723 { 2724 throw new GException( new ErrorG(err) ); 2725 } 2726 2727 if(__p is null) 2728 { 2729 return null; 2730 } 2731 2732 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) __p, true); 2733 } 2734 2735 /** 2736 * Asynchronously gets the requested information about the filesystem 2737 * that the specified @file is on. The result is a #GFileInfo object 2738 * that contains key-value attributes (such as type or size for the 2739 * file). 2740 * 2741 * For more details, see g_file_query_filesystem_info() which is the 2742 * synchronous version of this call. 2743 * 2744 * When the operation is finished, @callback will be called. You can 2745 * then call g_file_query_info_finish() to get the result of the 2746 * operation. 2747 * 2748 * Params: 2749 * attributes = an attribute query string 2750 * ioPriority = the [I/O priority][io-priority] of the request 2751 * cancellable = optional #GCancellable object, 2752 * %NULL to ignore 2753 * callback = a #GAsyncReadyCallback to call 2754 * when the request is satisfied 2755 * userData = the data to pass to callback function 2756 */ 2757 public void queryFilesystemInfoAsync(string attributes, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2758 { 2759 g_file_query_filesystem_info_async(getFileStruct(), Str.toStringz(attributes), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2760 } 2761 2762 /** 2763 * Finishes an asynchronous filesystem info query. 2764 * See g_file_query_filesystem_info_async(). 2765 * 2766 * Params: 2767 * res = a #GAsyncResult 2768 * 2769 * Returns: #GFileInfo for given @file 2770 * or %NULL on error. 2771 * Free the returned object with g_object_unref(). 2772 * 2773 * Throws: GException on failure. 2774 */ 2775 public FileInfo queryFilesystemInfoFinish(AsyncResultIF res) 2776 { 2777 GError* err = null; 2778 2779 auto __p = g_file_query_filesystem_info_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2780 2781 if (err !is null) 2782 { 2783 throw new GException( new ErrorG(err) ); 2784 } 2785 2786 if(__p is null) 2787 { 2788 return null; 2789 } 2790 2791 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) __p, true); 2792 } 2793 2794 /** 2795 * Gets the requested information about specified @file. 2796 * The result is a #GFileInfo object that contains key-value 2797 * attributes (such as the type or size of the file). 2798 * 2799 * The @attributes value is a string that specifies the file 2800 * attributes that should be gathered. It is not an error if 2801 * it's not possible to read a particular requested attribute 2802 * from a file - it just won't be set. @attributes should be a 2803 * comma-separated list of attributes or attribute wildcards. 2804 * The wildcard "*" means all attributes, and a wildcard like 2805 * "standard::*" means all attributes in the standard namespace. 2806 * An example attribute query be "standard::*,owner::user". 2807 * The standard attributes are available as defines, like 2808 * %G_FILE_ATTRIBUTE_STANDARD_NAME. 2809 * 2810 * If @cancellable is not %NULL, then the operation can be cancelled 2811 * by triggering the cancellable object from another thread. If the 2812 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 2813 * returned. 2814 * 2815 * For symlinks, normally the information about the target of the 2816 * symlink is returned, rather than information about the symlink 2817 * itself. However if you pass %G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS 2818 * in @flags the information about the symlink itself will be returned. 2819 * Also, for symlinks that point to non-existing files the information 2820 * about the symlink itself will be returned. 2821 * 2822 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 2823 * returned. Other errors are possible too, and depend on what kind of 2824 * filesystem the file is on. 2825 * 2826 * Params: 2827 * attributes = an attribute query string 2828 * flags = a set of #GFileQueryInfoFlags 2829 * cancellable = optional #GCancellable object, 2830 * %NULL to ignore 2831 * 2832 * Returns: a #GFileInfo for the given @file, or %NULL 2833 * on error. Free the returned object with g_object_unref(). 2834 * 2835 * Throws: GException on failure. 2836 */ 2837 public FileInfo queryInfo(string attributes, GFileQueryInfoFlags flags, Cancellable cancellable) 2838 { 2839 GError* err = null; 2840 2841 auto __p = g_file_query_info(getFileStruct(), Str.toStringz(attributes), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2842 2843 if (err !is null) 2844 { 2845 throw new GException( new ErrorG(err) ); 2846 } 2847 2848 if(__p is null) 2849 { 2850 return null; 2851 } 2852 2853 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) __p, true); 2854 } 2855 2856 /** 2857 * Asynchronously gets the requested information about specified @file. 2858 * The result is a #GFileInfo object that contains key-value attributes 2859 * (such as type or size for the file). 2860 * 2861 * For more details, see g_file_query_info() which is the synchronous 2862 * version of this call. 2863 * 2864 * When the operation is finished, @callback will be called. You can 2865 * then call g_file_query_info_finish() to get the result of the operation. 2866 * 2867 * Params: 2868 * attributes = an attribute query string 2869 * flags = a set of #GFileQueryInfoFlags 2870 * ioPriority = the [I/O priority][io-priority] of the request 2871 * cancellable = optional #GCancellable object, 2872 * %NULL to ignore 2873 * callback = a #GAsyncReadyCallback to call when the 2874 * request is satisfied 2875 * userData = the data to pass to callback function 2876 */ 2877 public void queryInfoAsync(string attributes, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 2878 { 2879 g_file_query_info_async(getFileStruct(), Str.toStringz(attributes), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 2880 } 2881 2882 /** 2883 * Finishes an asynchronous file info query. 2884 * See g_file_query_info_async(). 2885 * 2886 * Params: 2887 * res = a #GAsyncResult 2888 * 2889 * Returns: #GFileInfo for given @file 2890 * or %NULL on error. Free the returned object with 2891 * g_object_unref(). 2892 * 2893 * Throws: GException on failure. 2894 */ 2895 public FileInfo queryInfoFinish(AsyncResultIF res) 2896 { 2897 GError* err = null; 2898 2899 auto __p = g_file_query_info_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 2900 2901 if (err !is null) 2902 { 2903 throw new GException( new ErrorG(err) ); 2904 } 2905 2906 if(__p is null) 2907 { 2908 return null; 2909 } 2910 2911 return ObjectG.getDObject!(FileInfo)(cast(GFileInfo*) __p, true); 2912 } 2913 2914 /** 2915 * Obtain the list of settable attributes for the file. 2916 * 2917 * Returns the type and full attribute name of all the attributes 2918 * that can be set on this file. This doesn't mean setting it will 2919 * always succeed though, you might get an access failure, or some 2920 * specific file may not support a specific attribute. 2921 * 2922 * If @cancellable is not %NULL, then the operation can be cancelled by 2923 * triggering the cancellable object from another thread. If the operation 2924 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2925 * 2926 * Params: 2927 * cancellable = optional #GCancellable object, 2928 * %NULL to ignore 2929 * 2930 * Returns: a #GFileAttributeInfoList describing the settable attributes. 2931 * When you are done with it, release it with 2932 * g_file_attribute_info_list_unref() 2933 * 2934 * Throws: GException on failure. 2935 */ 2936 public FileAttributeInfoList querySettableAttributes(Cancellable cancellable) 2937 { 2938 GError* err = null; 2939 2940 auto __p = g_file_query_settable_attributes(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2941 2942 if (err !is null) 2943 { 2944 throw new GException( new ErrorG(err) ); 2945 } 2946 2947 if(__p is null) 2948 { 2949 return null; 2950 } 2951 2952 return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) __p, true); 2953 } 2954 2955 /** 2956 * Obtain the list of attribute namespaces where new attributes 2957 * can be created by a user. An example of this is extended 2958 * attributes (in the "xattr" namespace). 2959 * 2960 * If @cancellable is not %NULL, then the operation can be cancelled by 2961 * triggering the cancellable object from another thread. If the operation 2962 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 2963 * 2964 * Params: 2965 * cancellable = optional #GCancellable object, 2966 * %NULL to ignore 2967 * 2968 * Returns: a #GFileAttributeInfoList describing the writable namespaces. 2969 * When you are done with it, release it with 2970 * g_file_attribute_info_list_unref() 2971 * 2972 * Throws: GException on failure. 2973 */ 2974 public FileAttributeInfoList queryWritableNamespaces(Cancellable cancellable) 2975 { 2976 GError* err = null; 2977 2978 auto __p = g_file_query_writable_namespaces(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 2979 2980 if (err !is null) 2981 { 2982 throw new GException( new ErrorG(err) ); 2983 } 2984 2985 if(__p is null) 2986 { 2987 return null; 2988 } 2989 2990 return ObjectG.getDObject!(FileAttributeInfoList)(cast(GFileAttributeInfoList*) __p, true); 2991 } 2992 2993 /** 2994 * Opens a file for reading. The result is a #GFileInputStream that 2995 * can be used to read the contents of the file. 2996 * 2997 * If @cancellable is not %NULL, then the operation can be cancelled by 2998 * triggering the cancellable object from another thread. If the operation 2999 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3000 * 3001 * If the file does not exist, the %G_IO_ERROR_NOT_FOUND error will be 3002 * returned. If the file is a directory, the %G_IO_ERROR_IS_DIRECTORY 3003 * error will be returned. Other errors are possible too, and depend 3004 * on what kind of filesystem the file is on. 3005 * 3006 * Params: 3007 * cancellable = a #GCancellable 3008 * 3009 * Returns: #GFileInputStream or %NULL on error. 3010 * Free the returned object with g_object_unref(). 3011 * 3012 * Throws: GException on failure. 3013 */ 3014 public FileInputStream read(Cancellable cancellable) 3015 { 3016 GError* err = null; 3017 3018 auto __p = g_file_read(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3019 3020 if (err !is null) 3021 { 3022 throw new GException( new ErrorG(err) ); 3023 } 3024 3025 if(__p is null) 3026 { 3027 return null; 3028 } 3029 3030 return ObjectG.getDObject!(FileInputStream)(cast(GFileInputStream*) __p, true); 3031 } 3032 3033 /** 3034 * Asynchronously opens @file for reading. 3035 * 3036 * For more details, see g_file_read() which is 3037 * the synchronous version of this call. 3038 * 3039 * When the operation is finished, @callback will be called. 3040 * You can then call g_file_read_finish() to get the result 3041 * of the operation. 3042 * 3043 * Params: 3044 * ioPriority = the [I/O priority][io-priority] of the request 3045 * cancellable = optional #GCancellable object, 3046 * %NULL to ignore 3047 * callback = a #GAsyncReadyCallback to call 3048 * when the request is satisfied 3049 * userData = the data to pass to callback function 3050 */ 3051 public void readAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3052 { 3053 g_file_read_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3054 } 3055 3056 /** 3057 * Finishes an asynchronous file read operation started with 3058 * g_file_read_async(). 3059 * 3060 * Params: 3061 * res = a #GAsyncResult 3062 * 3063 * Returns: a #GFileInputStream or %NULL on error. 3064 * Free the returned object with g_object_unref(). 3065 * 3066 * Throws: GException on failure. 3067 */ 3068 public FileInputStream readFinish(AsyncResultIF res) 3069 { 3070 GError* err = null; 3071 3072 auto __p = g_file_read_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3073 3074 if (err !is null) 3075 { 3076 throw new GException( new ErrorG(err) ); 3077 } 3078 3079 if(__p is null) 3080 { 3081 return null; 3082 } 3083 3084 return ObjectG.getDObject!(FileInputStream)(cast(GFileInputStream*) __p, true); 3085 } 3086 3087 /** 3088 * Returns an output stream for overwriting the file, possibly 3089 * creating a backup copy of the file first. If the file doesn't exist, 3090 * it will be created. 3091 * 3092 * This will try to replace the file in the safest way possible so 3093 * that any errors during the writing will not affect an already 3094 * existing copy of the file. For instance, for local files it 3095 * may write to a temporary file and then atomically rename over 3096 * the destination when the stream is closed. 3097 * 3098 * By default files created are generally readable by everyone, 3099 * but if you pass %G_FILE_CREATE_PRIVATE in @flags the file 3100 * will be made readable only to the current user, to the level that 3101 * is supported on the target filesystem. 3102 * 3103 * If @cancellable is not %NULL, then the operation can be cancelled 3104 * by triggering the cancellable object from another thread. If the 3105 * operation was cancelled, the error %G_IO_ERROR_CANCELLED will be 3106 * returned. 3107 * 3108 * If you pass in a non-%NULL @etag value and @file already exists, then 3109 * this value is compared to the current entity tag of the file, and if 3110 * they differ an %G_IO_ERROR_WRONG_ETAG error is returned. This 3111 * generally means that the file has been changed since you last read 3112 * it. You can get the new etag from g_file_output_stream_get_etag() 3113 * after you've finished writing and closed the #GFileOutputStream. When 3114 * you load a new file you can use g_file_input_stream_query_info() to 3115 * get the etag of the file. 3116 * 3117 * If @make_backup is %TRUE, this function will attempt to make a 3118 * backup of the current file before overwriting it. If this fails 3119 * a %G_IO_ERROR_CANT_CREATE_BACKUP error will be returned. If you 3120 * want to replace anyway, try again with @make_backup set to %FALSE. 3121 * 3122 * If the file is a directory the %G_IO_ERROR_IS_DIRECTORY error will 3123 * be returned, and if the file is some other form of non-regular file 3124 * then a %G_IO_ERROR_NOT_REGULAR_FILE error will be returned. Some 3125 * file systems don't allow all file names, and may return an 3126 * %G_IO_ERROR_INVALID_FILENAME error, and if the name is to long 3127 * %G_IO_ERROR_FILENAME_TOO_LONG will be returned. Other errors are 3128 * possible too, and depend on what kind of filesystem the file is on. 3129 * 3130 * Params: 3131 * etag = an optional [entity tag][gfile-etag] 3132 * for the current #GFile, or #NULL to ignore 3133 * makeBackup = %TRUE if a backup should be created 3134 * flags = a set of #GFileCreateFlags 3135 * cancellable = optional #GCancellable object, 3136 * %NULL to ignore 3137 * 3138 * Returns: a #GFileOutputStream or %NULL on error. 3139 * Free the returned object with g_object_unref(). 3140 * 3141 * Throws: GException on failure. 3142 */ 3143 public FileOutputStream replace(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable) 3144 { 3145 GError* err = null; 3146 3147 auto __p = g_file_replace(getFileStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3148 3149 if (err !is null) 3150 { 3151 throw new GException( new ErrorG(err) ); 3152 } 3153 3154 if(__p is null) 3155 { 3156 return null; 3157 } 3158 3159 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) __p, true); 3160 } 3161 3162 /** 3163 * Asynchronously overwrites the file, replacing the contents, 3164 * possibly creating a backup copy of the file first. 3165 * 3166 * For more details, see g_file_replace() which is 3167 * the synchronous version of this call. 3168 * 3169 * When the operation is finished, @callback will be called. 3170 * You can then call g_file_replace_finish() to get the result 3171 * of the operation. 3172 * 3173 * Params: 3174 * etag = an [entity tag][gfile-etag] for the current #GFile, 3175 * or %NULL to ignore 3176 * makeBackup = %TRUE if a backup should be created 3177 * flags = a set of #GFileCreateFlags 3178 * ioPriority = the [I/O priority][io-priority] of the request 3179 * cancellable = optional #GCancellable object, 3180 * %NULL to ignore 3181 * callback = a #GAsyncReadyCallback to call 3182 * when the request is satisfied 3183 * userData = the data to pass to callback function 3184 */ 3185 public void replaceAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3186 { 3187 g_file_replace_async(getFileStruct(), Str.toStringz(etag), makeBackup, flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3188 } 3189 3190 /** 3191 * Replaces the contents of @file with @contents of @length bytes. 3192 * 3193 * If @etag is specified (not %NULL), any existing file must have that etag, 3194 * or the error %G_IO_ERROR_WRONG_ETAG will be returned. 3195 * 3196 * If @make_backup is %TRUE, this function will attempt to make a backup 3197 * of @file. Internally, it uses g_file_replace(), so will try to replace the 3198 * file contents in the safest way possible. For example, atomic renames are 3199 * used when replacing local files’ contents. 3200 * 3201 * If @cancellable is not %NULL, then the operation can be cancelled by 3202 * triggering the cancellable object from another thread. If the operation 3203 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3204 * 3205 * The returned @new_etag can be used to verify that the file hasn't 3206 * changed the next time it is saved over. 3207 * 3208 * Params: 3209 * contents = a string containing the new contents for @file 3210 * etag = the old [entity-tag][gfile-etag] for the document, 3211 * or %NULL 3212 * makeBackup = %TRUE if a backup should be created 3213 * flags = a set of #GFileCreateFlags 3214 * newEtag = a location to a new [entity tag][gfile-etag] 3215 * for the document. This should be freed with g_free() when no longer 3216 * needed, or %NULL 3217 * cancellable = optional #GCancellable object, %NULL to ignore 3218 * 3219 * Returns: %TRUE if successful. If an error has occurred, this function 3220 * will return %FALSE and set @error appropriately if present. 3221 * 3222 * Throws: GException on failure. 3223 */ 3224 public bool replaceContents(string contents, string etag, bool makeBackup, GFileCreateFlags flags, out string newEtag, Cancellable cancellable) 3225 { 3226 char* outnewEtag = null; 3227 GError* err = null; 3228 3229 auto __p = g_file_replace_contents(getFileStruct(), Str.toStringz(contents), cast(size_t)contents.length, Str.toStringz(etag), makeBackup, flags, &outnewEtag, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3230 3231 if (err !is null) 3232 { 3233 throw new GException( new ErrorG(err) ); 3234 } 3235 3236 newEtag = Str.toString(outnewEtag); 3237 3238 return __p; 3239 } 3240 3241 /** 3242 * Starts an asynchronous replacement of @file with the given 3243 * @contents of @length bytes. @etag will replace the document's 3244 * current entity tag. 3245 * 3246 * When this operation has completed, @callback will be called with 3247 * @user_user data, and the operation can be finalized with 3248 * g_file_replace_contents_finish(). 3249 * 3250 * If @cancellable is not %NULL, then the operation can be cancelled by 3251 * triggering the cancellable object from another thread. If the operation 3252 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3253 * 3254 * If @make_backup is %TRUE, this function will attempt to 3255 * make a backup of @file. 3256 * 3257 * Note that no copy of @contents will be made, so it must stay valid 3258 * until @callback is called. See g_file_replace_contents_bytes_async() 3259 * for a #GBytes version that will automatically hold a reference to the 3260 * contents (without copying) for the duration of the call. 3261 * 3262 * Params: 3263 * contents = string of contents to replace the file with 3264 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 3265 * makeBackup = %TRUE if a backup should be created 3266 * flags = a set of #GFileCreateFlags 3267 * cancellable = optional #GCancellable object, %NULL to ignore 3268 * callback = a #GAsyncReadyCallback to call when the request is satisfied 3269 * userData = the data to pass to callback function 3270 */ 3271 public void replaceContentsAsync(string contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3272 { 3273 g_file_replace_contents_async(getFileStruct(), Str.toStringz(contents), cast(size_t)contents.length, Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3274 } 3275 3276 /** 3277 * Same as g_file_replace_contents_async() but takes a #GBytes input instead. 3278 * This function will keep a ref on @contents until the operation is done. 3279 * Unlike g_file_replace_contents_async() this allows forgetting about the 3280 * content without waiting for the callback. 3281 * 3282 * When this operation has completed, @callback will be called with 3283 * @user_user data, and the operation can be finalized with 3284 * g_file_replace_contents_finish(). 3285 * 3286 * Params: 3287 * contents = a #GBytes 3288 * etag = a new [entity tag][gfile-etag] for the @file, or %NULL 3289 * makeBackup = %TRUE if a backup should be created 3290 * flags = a set of #GFileCreateFlags 3291 * cancellable = optional #GCancellable object, %NULL to ignore 3292 * callback = a #GAsyncReadyCallback to call when the request is satisfied 3293 * userData = the data to pass to callback function 3294 * 3295 * Since: 2.40 3296 */ 3297 public void replaceContentsBytesAsync(Bytes contents, string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3298 { 3299 g_file_replace_contents_bytes_async(getFileStruct(), (contents is null) ? null : contents.getBytesStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3300 } 3301 3302 /** 3303 * Finishes an asynchronous replace of the given @file. See 3304 * g_file_replace_contents_async(). Sets @new_etag to the new entity 3305 * tag for the document, if present. 3306 * 3307 * Params: 3308 * res = a #GAsyncResult 3309 * newEtag = a location of a new [entity tag][gfile-etag] 3310 * for the document. This should be freed with g_free() when it is no 3311 * longer needed, or %NULL 3312 * 3313 * Returns: %TRUE on success, %FALSE on failure. 3314 * 3315 * Throws: GException on failure. 3316 */ 3317 public bool replaceContentsFinish(AsyncResultIF res, out string newEtag) 3318 { 3319 char* outnewEtag = null; 3320 GError* err = null; 3321 3322 auto __p = g_file_replace_contents_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &outnewEtag, &err) != 0; 3323 3324 if (err !is null) 3325 { 3326 throw new GException( new ErrorG(err) ); 3327 } 3328 3329 newEtag = Str.toString(outnewEtag); 3330 3331 return __p; 3332 } 3333 3334 /** 3335 * Finishes an asynchronous file replace operation started with 3336 * g_file_replace_async(). 3337 * 3338 * Params: 3339 * res = a #GAsyncResult 3340 * 3341 * Returns: a #GFileOutputStream, or %NULL on error. 3342 * Free the returned object with g_object_unref(). 3343 * 3344 * Throws: GException on failure. 3345 */ 3346 public FileOutputStream replaceFinish(AsyncResultIF res) 3347 { 3348 GError* err = null; 3349 3350 auto __p = g_file_replace_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3351 3352 if (err !is null) 3353 { 3354 throw new GException( new ErrorG(err) ); 3355 } 3356 3357 if(__p is null) 3358 { 3359 return null; 3360 } 3361 3362 return ObjectG.getDObject!(FileOutputStream)(cast(GFileOutputStream*) __p, true); 3363 } 3364 3365 /** 3366 * Returns an output stream for overwriting the file in readwrite mode, 3367 * possibly creating a backup copy of the file first. If the file doesn't 3368 * exist, it will be created. 3369 * 3370 * For details about the behaviour, see g_file_replace() which does the 3371 * same thing but returns an output stream only. 3372 * 3373 * Note that in many non-local file cases read and write streams are not 3374 * supported, so make sure you really need to do read and write streaming, 3375 * rather than just opening for reading or writing. 3376 * 3377 * Params: 3378 * etag = an optional [entity tag][gfile-etag] 3379 * for the current #GFile, or #NULL to ignore 3380 * makeBackup = %TRUE if a backup should be created 3381 * flags = a set of #GFileCreateFlags 3382 * cancellable = optional #GCancellable object, 3383 * %NULL to ignore 3384 * 3385 * Returns: a #GFileIOStream or %NULL on error. 3386 * Free the returned object with g_object_unref(). 3387 * 3388 * Since: 2.22 3389 * 3390 * Throws: GException on failure. 3391 */ 3392 public FileIOStream replaceReadwrite(string etag, bool makeBackup, GFileCreateFlags flags, Cancellable cancellable) 3393 { 3394 GError* err = null; 3395 3396 auto __p = g_file_replace_readwrite(getFileStruct(), Str.toStringz(etag), makeBackup, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3397 3398 if (err !is null) 3399 { 3400 throw new GException( new ErrorG(err) ); 3401 } 3402 3403 if(__p is null) 3404 { 3405 return null; 3406 } 3407 3408 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) __p, true); 3409 } 3410 3411 /** 3412 * Asynchronously overwrites the file in read-write mode, 3413 * replacing the contents, possibly creating a backup copy 3414 * of the file first. 3415 * 3416 * For more details, see g_file_replace_readwrite() which is 3417 * the synchronous version of this call. 3418 * 3419 * When the operation is finished, @callback will be called. 3420 * You can then call g_file_replace_readwrite_finish() to get 3421 * the result of the operation. 3422 * 3423 * Params: 3424 * etag = an [entity tag][gfile-etag] for the current #GFile, 3425 * or %NULL to ignore 3426 * makeBackup = %TRUE if a backup should be created 3427 * flags = a set of #GFileCreateFlags 3428 * ioPriority = the [I/O priority][io-priority] of the request 3429 * cancellable = optional #GCancellable object, 3430 * %NULL to ignore 3431 * callback = a #GAsyncReadyCallback to call 3432 * when the request is satisfied 3433 * userData = the data to pass to callback function 3434 * 3435 * Since: 2.22 3436 */ 3437 public void replaceReadwriteAsync(string etag, bool makeBackup, GFileCreateFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3438 { 3439 g_file_replace_readwrite_async(getFileStruct(), Str.toStringz(etag), makeBackup, flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3440 } 3441 3442 /** 3443 * Finishes an asynchronous file replace operation started with 3444 * g_file_replace_readwrite_async(). 3445 * 3446 * Params: 3447 * res = a #GAsyncResult 3448 * 3449 * Returns: a #GFileIOStream, or %NULL on error. 3450 * Free the returned object with g_object_unref(). 3451 * 3452 * Since: 2.22 3453 * 3454 * Throws: GException on failure. 3455 */ 3456 public FileIOStream replaceReadwriteFinish(AsyncResultIF res) 3457 { 3458 GError* err = null; 3459 3460 auto __p = g_file_replace_readwrite_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3461 3462 if (err !is null) 3463 { 3464 throw new GException( new ErrorG(err) ); 3465 } 3466 3467 if(__p is null) 3468 { 3469 return null; 3470 } 3471 3472 return ObjectG.getDObject!(FileIOStream)(cast(GFileIOStream*) __p, true); 3473 } 3474 3475 /** 3476 * Resolves a relative path for @file to an absolute path. 3477 * 3478 * This call does no blocking I/O. 3479 * 3480 * If the @relative_path is an absolute path name, the resolution 3481 * is done absolutely (without taking @file path as base). 3482 * 3483 * Params: 3484 * relativePath = a given relative path string 3485 * 3486 * Returns: a #GFile for the resolved path. 3487 */ 3488 public FileIF resolveRelativePath(string relativePath) 3489 { 3490 auto __p = g_file_resolve_relative_path(getFileStruct(), Str.toStringz(relativePath)); 3491 3492 if(__p is null) 3493 { 3494 return null; 3495 } 3496 3497 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 3498 } 3499 3500 /** 3501 * Sets an attribute in the file with attribute name @attribute to @value_p. 3502 * 3503 * Some attributes can be unset by setting @type to 3504 * %G_FILE_ATTRIBUTE_TYPE_INVALID and @value_p to %NULL. 3505 * 3506 * If @cancellable is not %NULL, then the operation can be cancelled by 3507 * triggering the cancellable object from another thread. If the operation 3508 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3509 * 3510 * Params: 3511 * attribute = a string containing the attribute's name 3512 * type = The type of the attribute 3513 * valueP = a pointer to the value (or the pointer 3514 * itself if the type is a pointer type) 3515 * flags = a set of #GFileQueryInfoFlags 3516 * cancellable = optional #GCancellable object, 3517 * %NULL to ignore 3518 * 3519 * Returns: %TRUE if the attribute was set, %FALSE otherwise. 3520 * 3521 * Throws: GException on failure. 3522 */ 3523 public bool setAttribute(string attribute, GFileAttributeType type, void* valueP, GFileQueryInfoFlags flags, Cancellable cancellable) 3524 { 3525 GError* err = null; 3526 3527 auto __p = g_file_set_attribute(getFileStruct(), Str.toStringz(attribute), type, valueP, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3528 3529 if (err !is null) 3530 { 3531 throw new GException( new ErrorG(err) ); 3532 } 3533 3534 return __p; 3535 } 3536 3537 /** 3538 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_BYTE_STRING to @value. 3539 * If @attribute is of a different type, this operation will fail, 3540 * returning %FALSE. 3541 * 3542 * If @cancellable is not %NULL, then the operation can be cancelled by 3543 * triggering the cancellable object from another thread. If the operation 3544 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3545 * 3546 * Params: 3547 * attribute = a string containing the attribute's name 3548 * value = a string containing the attribute's new value 3549 * flags = a #GFileQueryInfoFlags 3550 * cancellable = optional #GCancellable object, 3551 * %NULL to ignore 3552 * 3553 * Returns: %TRUE if the @attribute was successfully set to @value 3554 * in the @file, %FALSE otherwise. 3555 * 3556 * Throws: GException on failure. 3557 */ 3558 public bool setAttributeByteString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable) 3559 { 3560 GError* err = null; 3561 3562 auto __p = g_file_set_attribute_byte_string(getFileStruct(), Str.toStringz(attribute), Str.toStringz(value), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3563 3564 if (err !is null) 3565 { 3566 throw new GException( new ErrorG(err) ); 3567 } 3568 3569 return __p; 3570 } 3571 3572 /** 3573 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT32 to @value. 3574 * If @attribute is of a different type, this operation will fail. 3575 * 3576 * If @cancellable is not %NULL, then the operation can be cancelled by 3577 * triggering the cancellable object from another thread. If the operation 3578 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3579 * 3580 * Params: 3581 * attribute = a string containing the attribute's name 3582 * value = a #gint32 containing the attribute's new value 3583 * flags = a #GFileQueryInfoFlags 3584 * cancellable = optional #GCancellable object, 3585 * %NULL to ignore 3586 * 3587 * Returns: %TRUE if the @attribute was successfully set to @value 3588 * in the @file, %FALSE otherwise. 3589 * 3590 * Throws: GException on failure. 3591 */ 3592 public bool setAttributeInt32(string attribute, int value, GFileQueryInfoFlags flags, Cancellable cancellable) 3593 { 3594 GError* err = null; 3595 3596 auto __p = g_file_set_attribute_int32(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3597 3598 if (err !is null) 3599 { 3600 throw new GException( new ErrorG(err) ); 3601 } 3602 3603 return __p; 3604 } 3605 3606 /** 3607 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_INT64 to @value. 3608 * If @attribute is of a different type, this operation will fail. 3609 * 3610 * If @cancellable is not %NULL, then the operation can be cancelled by 3611 * triggering the cancellable object from another thread. If the operation 3612 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3613 * 3614 * Params: 3615 * attribute = a string containing the attribute's name 3616 * value = a #guint64 containing the attribute's new value 3617 * flags = a #GFileQueryInfoFlags 3618 * cancellable = optional #GCancellable object, 3619 * %NULL to ignore 3620 * 3621 * Returns: %TRUE if the @attribute was successfully set, %FALSE otherwise. 3622 * 3623 * Throws: GException on failure. 3624 */ 3625 public bool setAttributeInt64(string attribute, long value, GFileQueryInfoFlags flags, Cancellable cancellable) 3626 { 3627 GError* err = null; 3628 3629 auto __p = g_file_set_attribute_int64(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3630 3631 if (err !is null) 3632 { 3633 throw new GException( new ErrorG(err) ); 3634 } 3635 3636 return __p; 3637 } 3638 3639 /** 3640 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_STRING to @value. 3641 * If @attribute is of a different type, this operation will fail. 3642 * 3643 * If @cancellable is not %NULL, then the operation can be cancelled by 3644 * triggering the cancellable object from another thread. If the operation 3645 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3646 * 3647 * Params: 3648 * attribute = a string containing the attribute's name 3649 * value = a string containing the attribute's value 3650 * flags = #GFileQueryInfoFlags 3651 * cancellable = optional #GCancellable object, 3652 * %NULL to ignore 3653 * 3654 * Returns: %TRUE if the @attribute was successfully set, %FALSE otherwise. 3655 * 3656 * Throws: GException on failure. 3657 */ 3658 public bool setAttributeString(string attribute, string value, GFileQueryInfoFlags flags, Cancellable cancellable) 3659 { 3660 GError* err = null; 3661 3662 auto __p = g_file_set_attribute_string(getFileStruct(), Str.toStringz(attribute), Str.toStringz(value), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3663 3664 if (err !is null) 3665 { 3666 throw new GException( new ErrorG(err) ); 3667 } 3668 3669 return __p; 3670 } 3671 3672 /** 3673 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT32 to @value. 3674 * If @attribute is of a different type, this operation will fail. 3675 * 3676 * If @cancellable is not %NULL, then the operation can be cancelled by 3677 * triggering the cancellable object from another thread. If the operation 3678 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3679 * 3680 * Params: 3681 * attribute = a string containing the attribute's name 3682 * value = a #guint32 containing the attribute's new value 3683 * flags = a #GFileQueryInfoFlags 3684 * cancellable = optional #GCancellable object, 3685 * %NULL to ignore 3686 * 3687 * Returns: %TRUE if the @attribute was successfully set to @value 3688 * in the @file, %FALSE otherwise. 3689 * 3690 * Throws: GException on failure. 3691 */ 3692 public bool setAttributeUint32(string attribute, uint value, GFileQueryInfoFlags flags, Cancellable cancellable) 3693 { 3694 GError* err = null; 3695 3696 auto __p = g_file_set_attribute_uint32(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3697 3698 if (err !is null) 3699 { 3700 throw new GException( new ErrorG(err) ); 3701 } 3702 3703 return __p; 3704 } 3705 3706 /** 3707 * Sets @attribute of type %G_FILE_ATTRIBUTE_TYPE_UINT64 to @value. 3708 * If @attribute is of a different type, this operation will fail. 3709 * 3710 * If @cancellable is not %NULL, then the operation can be cancelled by 3711 * triggering the cancellable object from another thread. If the operation 3712 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3713 * 3714 * Params: 3715 * attribute = a string containing the attribute's name 3716 * value = a #guint64 containing the attribute's new value 3717 * flags = a #GFileQueryInfoFlags 3718 * cancellable = optional #GCancellable object, 3719 * %NULL to ignore 3720 * 3721 * Returns: %TRUE if the @attribute was successfully set to @value 3722 * in the @file, %FALSE otherwise. 3723 * 3724 * Throws: GException on failure. 3725 */ 3726 public bool setAttributeUint64(string attribute, ulong value, GFileQueryInfoFlags flags, Cancellable cancellable) 3727 { 3728 GError* err = null; 3729 3730 auto __p = g_file_set_attribute_uint64(getFileStruct(), Str.toStringz(attribute), value, flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3731 3732 if (err !is null) 3733 { 3734 throw new GException( new ErrorG(err) ); 3735 } 3736 3737 return __p; 3738 } 3739 3740 /** 3741 * Asynchronously sets the attributes of @file with @info. 3742 * 3743 * For more details, see g_file_set_attributes_from_info(), 3744 * which is the synchronous version of this call. 3745 * 3746 * When the operation is finished, @callback will be called. 3747 * You can then call g_file_set_attributes_finish() to get 3748 * the result of the operation. 3749 * 3750 * Params: 3751 * info = a #GFileInfo 3752 * flags = a #GFileQueryInfoFlags 3753 * ioPriority = the [I/O priority][io-priority] of the request 3754 * cancellable = optional #GCancellable object, 3755 * %NULL to ignore 3756 * callback = a #GAsyncReadyCallback 3757 * userData = a #gpointer 3758 */ 3759 public void setAttributesAsync(FileInfo info, GFileQueryInfoFlags flags, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3760 { 3761 g_file_set_attributes_async(getFileStruct(), (info is null) ? null : info.getFileInfoStruct(), flags, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3762 } 3763 3764 /** 3765 * Finishes setting an attribute started in g_file_set_attributes_async(). 3766 * 3767 * Params: 3768 * result = a #GAsyncResult 3769 * info = a #GFileInfo 3770 * 3771 * Returns: %TRUE if the attributes were set correctly, %FALSE otherwise. 3772 * 3773 * Throws: GException on failure. 3774 */ 3775 public bool setAttributesFinish(AsyncResultIF result, out FileInfo info) 3776 { 3777 GFileInfo* outinfo = null; 3778 GError* err = null; 3779 3780 auto __p = g_file_set_attributes_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &outinfo, &err) != 0; 3781 3782 if (err !is null) 3783 { 3784 throw new GException( new ErrorG(err) ); 3785 } 3786 3787 info = ObjectG.getDObject!(FileInfo)(outinfo); 3788 3789 return __p; 3790 } 3791 3792 /** 3793 * Tries to set all attributes in the #GFileInfo on the target 3794 * values, not stopping on the first error. 3795 * 3796 * If there is any error during this operation then @error will 3797 * be set to the first error. Error on particular fields are flagged 3798 * by setting the "status" field in the attribute value to 3799 * %G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, which means you can 3800 * also detect further errors. 3801 * 3802 * If @cancellable is not %NULL, then the operation can be cancelled by 3803 * triggering the cancellable object from another thread. If the operation 3804 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3805 * 3806 * Params: 3807 * info = a #GFileInfo 3808 * flags = #GFileQueryInfoFlags 3809 * cancellable = optional #GCancellable object, 3810 * %NULL to ignore 3811 * 3812 * Returns: %FALSE if there was any error, %TRUE otherwise. 3813 * 3814 * Throws: GException on failure. 3815 */ 3816 public bool setAttributesFromInfo(FileInfo info, GFileQueryInfoFlags flags, Cancellable cancellable) 3817 { 3818 GError* err = null; 3819 3820 auto __p = g_file_set_attributes_from_info(getFileStruct(), (info is null) ? null : info.getFileInfoStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 3821 3822 if (err !is null) 3823 { 3824 throw new GException( new ErrorG(err) ); 3825 } 3826 3827 return __p; 3828 } 3829 3830 /** 3831 * Renames @file to the specified display name. 3832 * 3833 * The display name is converted from UTF-8 to the correct encoding 3834 * for the target filesystem if possible and the @file is renamed to this. 3835 * 3836 * If you want to implement a rename operation in the user interface the 3837 * edit name (%G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) should be used as the 3838 * initial value in the rename widget, and then the result after editing 3839 * should be passed to g_file_set_display_name(). 3840 * 3841 * On success the resulting converted filename is returned. 3842 * 3843 * If @cancellable is not %NULL, then the operation can be cancelled by 3844 * triggering the cancellable object from another thread. If the operation 3845 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3846 * 3847 * Params: 3848 * displayName = a string 3849 * cancellable = optional #GCancellable object, 3850 * %NULL to ignore 3851 * 3852 * Returns: a #GFile specifying what @file was renamed to, 3853 * or %NULL if there was an error. 3854 * Free the returned object with g_object_unref(). 3855 * 3856 * Throws: GException on failure. 3857 */ 3858 public FileIF setDisplayName(string displayName, Cancellable cancellable) 3859 { 3860 GError* err = null; 3861 3862 auto __p = g_file_set_display_name(getFileStruct(), Str.toStringz(displayName), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 3863 3864 if (err !is null) 3865 { 3866 throw new GException( new ErrorG(err) ); 3867 } 3868 3869 if(__p is null) 3870 { 3871 return null; 3872 } 3873 3874 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 3875 } 3876 3877 /** 3878 * Asynchronously sets the display name for a given #GFile. 3879 * 3880 * For more details, see g_file_set_display_name() which is 3881 * the synchronous version of this call. 3882 * 3883 * When the operation is finished, @callback will be called. 3884 * You can then call g_file_set_display_name_finish() to get 3885 * the result of the operation. 3886 * 3887 * Params: 3888 * displayName = a string 3889 * ioPriority = the [I/O priority][io-priority] of the request 3890 * cancellable = optional #GCancellable object, 3891 * %NULL to ignore 3892 * callback = a #GAsyncReadyCallback to call 3893 * when the request is satisfied 3894 * userData = the data to pass to callback function 3895 */ 3896 public void setDisplayNameAsync(string displayName, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3897 { 3898 g_file_set_display_name_async(getFileStruct(), Str.toStringz(displayName), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3899 } 3900 3901 /** 3902 * Finishes setting a display name started with 3903 * g_file_set_display_name_async(). 3904 * 3905 * Params: 3906 * res = a #GAsyncResult 3907 * 3908 * Returns: a #GFile or %NULL on error. 3909 * Free the returned object with g_object_unref(). 3910 * 3911 * Throws: GException on failure. 3912 */ 3913 public FileIF setDisplayNameFinish(AsyncResultIF res) 3914 { 3915 GError* err = null; 3916 3917 auto __p = g_file_set_display_name_finish(getFileStruct(), (res is null) ? null : res.getAsyncResultStruct(), &err); 3918 3919 if (err !is null) 3920 { 3921 throw new GException( new ErrorG(err) ); 3922 } 3923 3924 if(__p is null) 3925 { 3926 return null; 3927 } 3928 3929 return ObjectG.getDObject!(FileIF)(cast(GFile*) __p, true); 3930 } 3931 3932 /** 3933 * Starts a file of type %G_FILE_TYPE_MOUNTABLE. 3934 * Using @start_operation, you can request callbacks when, for instance, 3935 * passwords are needed during authentication. 3936 * 3937 * If @cancellable is not %NULL, then the operation can be cancelled by 3938 * triggering the cancellable object from another thread. If the operation 3939 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3940 * 3941 * When the operation is finished, @callback will be called. 3942 * You can then call g_file_mount_mountable_finish() to get 3943 * the result of the operation. 3944 * 3945 * Params: 3946 * flags = flags affecting the operation 3947 * startOperation = a #GMountOperation, or %NULL to avoid user interaction 3948 * cancellable = optional #GCancellable object, %NULL to ignore 3949 * callback = a #GAsyncReadyCallback to call when the request is satisfied, or %NULL 3950 * userData = the data to pass to callback function 3951 * 3952 * Since: 2.22 3953 */ 3954 public void startMountable(GDriveStartFlags flags, MountOperation startOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 3955 { 3956 g_file_start_mountable(getFileStruct(), flags, (startOperation is null) ? null : startOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 3957 } 3958 3959 /** 3960 * Finishes a start operation. See g_file_start_mountable() for details. 3961 * 3962 * Finish an asynchronous start operation that was started 3963 * with g_file_start_mountable(). 3964 * 3965 * Params: 3966 * result = a #GAsyncResult 3967 * 3968 * Returns: %TRUE if the operation finished successfully. %FALSE 3969 * otherwise. 3970 * 3971 * Since: 2.22 3972 * 3973 * Throws: GException on failure. 3974 */ 3975 public bool startMountableFinish(AsyncResultIF result) 3976 { 3977 GError* err = null; 3978 3979 auto __p = g_file_start_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 3980 3981 if (err !is null) 3982 { 3983 throw new GException( new ErrorG(err) ); 3984 } 3985 3986 return __p; 3987 } 3988 3989 /** 3990 * Stops a file of type %G_FILE_TYPE_MOUNTABLE. 3991 * 3992 * If @cancellable is not %NULL, then the operation can be cancelled by 3993 * triggering the cancellable object from another thread. If the operation 3994 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 3995 * 3996 * When the operation is finished, @callback will be called. 3997 * You can then call g_file_stop_mountable_finish() to get 3998 * the result of the operation. 3999 * 4000 * Params: 4001 * flags = flags affecting the operation 4002 * mountOperation = a #GMountOperation, 4003 * or %NULL to avoid user interaction. 4004 * cancellable = optional #GCancellable object, 4005 * %NULL to ignore 4006 * callback = a #GAsyncReadyCallback to call 4007 * when the request is satisfied, or %NULL 4008 * userData = the data to pass to callback function 4009 * 4010 * Since: 2.22 4011 */ 4012 public void stopMountable(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 4013 { 4014 g_file_stop_mountable(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 4015 } 4016 4017 /** 4018 * Finishes a stop operation, see g_file_stop_mountable() for details. 4019 * 4020 * Finish an asynchronous stop operation that was started 4021 * with g_file_stop_mountable(). 4022 * 4023 * Params: 4024 * result = a #GAsyncResult 4025 * 4026 * Returns: %TRUE if the operation finished successfully. 4027 * %FALSE otherwise. 4028 * 4029 * Since: 2.22 4030 * 4031 * Throws: GException on failure. 4032 */ 4033 public bool stopMountableFinish(AsyncResultIF result) 4034 { 4035 GError* err = null; 4036 4037 auto __p = g_file_stop_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 4038 4039 if (err !is null) 4040 { 4041 throw new GException( new ErrorG(err) ); 4042 } 4043 4044 return __p; 4045 } 4046 4047 /** 4048 * Checks if @file supports 4049 * [thread-default contexts][g-main-context-push-thread-default-context]. 4050 * If this returns %FALSE, you cannot perform asynchronous operations on 4051 * @file in a thread that has a thread-default context. 4052 * 4053 * Returns: Whether or not @file supports thread-default contexts. 4054 * 4055 * Since: 2.22 4056 */ 4057 public bool supportsThreadContexts() 4058 { 4059 return g_file_supports_thread_contexts(getFileStruct()) != 0; 4060 } 4061 4062 /** 4063 * Sends @file to the "Trashcan", if possible. This is similar to 4064 * deleting it, but the user can recover it before emptying the trashcan. 4065 * Not all file systems support trashing, so this call can return the 4066 * %G_IO_ERROR_NOT_SUPPORTED error. Since GLib 2.66, the `x-gvfs-notrash` unix 4067 * mount option can be used to disable g_file_trash() support for certain 4068 * mounts, the %G_IO_ERROR_NOT_SUPPORTED error will be returned in that case. 4069 * 4070 * If @cancellable is not %NULL, then the operation can be cancelled by 4071 * triggering the cancellable object from another thread. If the operation 4072 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 4073 * 4074 * Params: 4075 * cancellable = optional #GCancellable object, 4076 * %NULL to ignore 4077 * 4078 * Returns: %TRUE on successful trash, %FALSE otherwise. 4079 * 4080 * Throws: GException on failure. 4081 */ 4082 public bool trash(Cancellable cancellable) 4083 { 4084 GError* err = null; 4085 4086 auto __p = g_file_trash(getFileStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 4087 4088 if (err !is null) 4089 { 4090 throw new GException( new ErrorG(err) ); 4091 } 4092 4093 return __p; 4094 } 4095 4096 /** 4097 * Asynchronously sends @file to the Trash location, if possible. 4098 * 4099 * Params: 4100 * ioPriority = the [I/O priority][io-priority] of the request 4101 * cancellable = optional #GCancellable object, 4102 * %NULL to ignore 4103 * callback = a #GAsyncReadyCallback to call 4104 * when the request is satisfied 4105 * userData = the data to pass to callback function 4106 * 4107 * Since: 2.38 4108 */ 4109 public void trashAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 4110 { 4111 g_file_trash_async(getFileStruct(), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 4112 } 4113 4114 /** 4115 * Finishes an asynchronous file trashing operation, started with 4116 * g_file_trash_async(). 4117 * 4118 * Params: 4119 * result = a #GAsyncResult 4120 * 4121 * Returns: %TRUE on successful trash, %FALSE otherwise. 4122 * 4123 * Since: 2.38 4124 * 4125 * Throws: GException on failure. 4126 */ 4127 public bool trashFinish(AsyncResultIF result) 4128 { 4129 GError* err = null; 4130 4131 auto __p = g_file_trash_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 4132 4133 if (err !is null) 4134 { 4135 throw new GException( new ErrorG(err) ); 4136 } 4137 4138 return __p; 4139 } 4140 4141 /** 4142 * Unmounts a file of type G_FILE_TYPE_MOUNTABLE. 4143 * 4144 * If @cancellable is not %NULL, then the operation can be cancelled by 4145 * triggering the cancellable object from another thread. If the operation 4146 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 4147 * 4148 * When the operation is finished, @callback will be called. 4149 * You can then call g_file_unmount_mountable_finish() to get 4150 * the result of the operation. 4151 * 4152 * Deprecated: Use g_file_unmount_mountable_with_operation() instead. 4153 * 4154 * Params: 4155 * flags = flags affecting the operation 4156 * cancellable = optional #GCancellable object, 4157 * %NULL to ignore 4158 * callback = a #GAsyncReadyCallback to call 4159 * when the request is satisfied, or %NULL 4160 * userData = the data to pass to callback function 4161 */ 4162 public void unmountMountable(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 4163 { 4164 g_file_unmount_mountable(getFileStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 4165 } 4166 4167 /** 4168 * Finishes an unmount operation, see g_file_unmount_mountable() for details. 4169 * 4170 * Finish an asynchronous unmount operation that was started 4171 * with g_file_unmount_mountable(). 4172 * 4173 * Deprecated: Use g_file_unmount_mountable_with_operation_finish() 4174 * instead. 4175 * 4176 * Params: 4177 * result = a #GAsyncResult 4178 * 4179 * Returns: %TRUE if the operation finished successfully. 4180 * %FALSE otherwise. 4181 * 4182 * Throws: GException on failure. 4183 */ 4184 public bool unmountMountableFinish(AsyncResultIF result) 4185 { 4186 GError* err = null; 4187 4188 auto __p = g_file_unmount_mountable_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 4189 4190 if (err !is null) 4191 { 4192 throw new GException( new ErrorG(err) ); 4193 } 4194 4195 return __p; 4196 } 4197 4198 /** 4199 * Unmounts a file of type %G_FILE_TYPE_MOUNTABLE. 4200 * 4201 * If @cancellable is not %NULL, then the operation can be cancelled by 4202 * triggering the cancellable object from another thread. If the operation 4203 * was cancelled, the error %G_IO_ERROR_CANCELLED will be returned. 4204 * 4205 * When the operation is finished, @callback will be called. 4206 * You can then call g_file_unmount_mountable_finish() to get 4207 * the result of the operation. 4208 * 4209 * Params: 4210 * flags = flags affecting the operation 4211 * mountOperation = a #GMountOperation, 4212 * or %NULL to avoid user interaction 4213 * cancellable = optional #GCancellable object, 4214 * %NULL to ignore 4215 * callback = a #GAsyncReadyCallback to call 4216 * when the request is satisfied, or %NULL 4217 * userData = the data to pass to callback function 4218 * 4219 * Since: 2.22 4220 */ 4221 public void unmountMountableWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 4222 { 4223 g_file_unmount_mountable_with_operation(getFileStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 4224 } 4225 4226 /** 4227 * Finishes an unmount operation, 4228 * see g_file_unmount_mountable_with_operation() for details. 4229 * 4230 * Finish an asynchronous unmount operation that was started 4231 * with g_file_unmount_mountable_with_operation(). 4232 * 4233 * Params: 4234 * result = a #GAsyncResult 4235 * 4236 * Returns: %TRUE if the operation finished successfully. 4237 * %FALSE otherwise. 4238 * 4239 * Since: 2.22 4240 * 4241 * Throws: GException on failure. 4242 */ 4243 public bool unmountMountableWithOperationFinish(AsyncResultIF result) 4244 { 4245 GError* err = null; 4246 4247 auto __p = g_file_unmount_mountable_with_operation_finish(getFileStruct(), (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 4248 4249 if (err !is null) 4250 { 4251 throw new GException( new ErrorG(err) ); 4252 } 4253 4254 return __p; 4255 } 4256 }